Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional dependent null #24856

Merged
merged 29 commits into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
fdb07fc
Perf: unset EnableContentResponseOnWrite #22999
umitkavala Nov 13, 2020
a772ec2
Revert "Perf: unset EnableContentResponseOnWrite #22999"
umitkavala Nov 13, 2020
18b340b
Merge remote-tracking branch 'upstream/main' into main
umitkavala Nov 16, 2020
cce3889
Merge remote-tracking branch 'upstream/main' into main
umitkavala Dec 1, 2020
b8ea6fd
Merge remote-tracking branch 'upstream/main' into main
umitkavala Dec 2, 2020
bd2f03d
Merge remote-tracking branch 'upstream/main' into main
umitkavala Apr 3, 2021
ffdfd9d
Merge remote-tracking branch 'upstream/main' into main
kavalau Apr 9, 2021
0e13a04
Merge remote-tracking branch 'upstream/main' into optional-dependent-…
umitkavala May 6, 2021
495e910
Added test to reproduce issue.
umitkavala May 8, 2021
6e613f9
Log optional dependent
umitkavala May 11, 2021
8dfc5e8
Complete method & Add new test
umitkavala May 15, 2021
7ae83fe
refactor to fix existing test case fails
umitkavala May 16, 2021
0248223
Update SharedTableEntryMap.cs
umitkavala May 16, 2021
0156282
Update SharedTableEntryMap.cs
umitkavala May 16, 2021
de2ce07
Merge remote-tracking branch 'upstream/main' into optional-dependent-…
umitkavala May 24, 2021
d4c962f
Move check to ModificationCommand.GenerateColumnModifications
umitkavala May 24, 2021
b90d566
Fix failed test cases.
umitkavala May 24, 2021
cb29589
Update ModificationCommand.cs
umitkavala May 25, 2021
f46926f
log warning instead throw exception
umitkavala May 25, 2021
ca9ff1f
Update ModificationCommand.cs
umitkavala May 25, 2021
b882981
Revert "Update ModificationCommand.cs"
umitkavala May 25, 2021
978befd
Revert "log warning instead throw exception"
umitkavala May 25, 2021
fdda7a7
pass logger to ModificationCommand constructor
umitkavala May 25, 2021
3ad496a
pass new parameter in tests
umitkavala May 25, 2021
de6618e
add sensitive data to event data. typo on warning message
umitkavala May 26, 2021
82046e5
create new eventId & move models to under base test classs
kavalau May 26, 2021
f2579fe
update comments
umitkavala May 27, 2021
c3b64f7
Update RelationalEventId.cs
umitkavala May 28, 2021
5728d14
test fix
umitkavala May 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.TestModels.QueryModel;
using Microsoft.EntityFrameworkCore.TestModels.TransportationModel;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Xunit;
Expand Down Expand Up @@ -548,6 +549,48 @@ public virtual async Task Optional_dependent_materialized_when_no_properties()
}
}

[ConditionalFact]
public virtual async Task Warn_When_Save_Optional_dependent_with_null_values()
{
await InitializeAsync(
modelBuilder =>
{
modelBuilder.Entity<MeterReadingDetails>(
dob =>
{
dob.ToTable("MeterReadings");
dob.Property(o => o.ReadingStatus).HasColumnName("ReadingStatus");
});

modelBuilder.Entity<MeterReading>(
ob =>
{
ob.ToTable("MeterReadings");
ob.Property(o => o.ReadingStatus).HasColumnName("ReadingStatus");
ob.HasOne(o => o.MeterReadingDetails).WithOne()
.HasForeignKey<MeterReadingDetails>(o => o.Id);
});
}
);

umitkavala marked this conversation as resolved.
Show resolved Hide resolved
using (var context = CreateContext())
{
var scooterEntry = context.Add(
new MeterReading
{
MeterReadingDetails = new MeterReadingDetails()
});

context.SaveChanges();
}

using (var context = CreateContext())
{
var reading = context.Set<MeterReading>().Include(o => o.MeterReadingDetails).OrderBy(o => o.Id).First();
Assert.Null(reading.MeterReadingDetails);
}
}

protected override string StoreName { get; } = "TableSplittingTest";
protected TestSqlLoggerFactory TestSqlLoggerFactory
=> (TestSqlLoggerFactory)ListLoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

namespace Microsoft.EntityFrameworkCore.TestModels.QueryModel
{
public class MeterReading
{
public int Id { get; set; }
public MeterReadingStatus? ReadingStatus { get; set; }
public MeterReadingDetails MeterReadingDetails { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

namespace Microsoft.EntityFrameworkCore.TestModels.QueryModel
{
public class MeterReadingDetails
{
public int Id { get; set; }
public MeterReadingStatus? ReadingStatus { get; set; }
public string CurrentRead { get; set; }
public string PreviousRead { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

namespace Microsoft.EntityFrameworkCore.TestModels.QueryModel
{
public enum MeterReadingStatus
{
Running=0,
NotAccesible=2
}
}