Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -320,7 +320,7 @@ bool TryRewriteComplexTypeEquality(bool collection, [NotNullWhen(true)] out SqlE
var boolTypeMapping = Dependencies.TypeMappingSource.FindMapping(typeof(bool))!;
SqlExpression? comparisons = null;

if (!TryGenerateComparisons(complexType, left, right, ref comparisons))
if (!TryGenerateComparisons(complexType, left, right, ref comparisons, out _))
{
result = null;
return false;
Expand All @@ -333,9 +333,7 @@ bool TryRewriteComplexTypeEquality(bool collection, [NotNullWhen(true)] out SqlE
// into complex properties to generate a flattened list of comparisons.
// The moment we reach a a complex property that's mapped to JSON, we stop and generate a single comparison
// for the whole complex type.
bool TryGenerateComparisons(IComplexType complexType, Expression left, Expression right, [NotNullWhen(true)] ref SqlExpression? comparisons)
=> TryGenerateComparisonsRec(complexType, left, right, ref comparisons, out _);
bool TryGenerateComparisonsRec(IComplexType type, Expression left, Expression right, [NotNullWhen(true)] ref SqlExpression? comparisons, out bool exitImmediately)
bool TryGenerateComparisons(IComplexType type, Expression left, Expression right, [NotNullWhen(true)] ref SqlExpression? comparisons, out bool exitImmediately)
{
exitImmediately = false;

Expand All @@ -346,6 +344,9 @@ bool TryGenerateComparisonsRec(IComplexType type, Expression left, Expression ri

var comparison = _sqlExpressionFactory.MakeBinary(nodeType, leftScalar, rightScalar, boolTypeMapping)!;

// A single JSON-mapped complex type requires only a single comparison for the JSON value/column on each side;
// but the JSON-mapped complex type may be nested inside a non-JSON (table-split) complex type, in which
// case this is just one comparison in several.
comparisons = comparisons is null
? comparison
: nodeType == ExpressionType.Equal
Expand Down Expand Up @@ -458,7 +459,7 @@ SqlParameterExpression parameter

if (nestedLeft is null
|| nestedRight is null
|| !TryGenerateComparisonsRec(complexProperty.ComplexType, nestedLeft, nestedRight, ref comparisons, out exitImmediately))
|| !TryGenerateComparisons(complexProperty.ComplexType, nestedLeft, nestedRight, ref comparisons, out exitImmediately))
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public override async Task Index_parameter()

AssertSql(
"""
@i=?
@i='0'

SELECT VALUE c
FROM root c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ protected override ITestStoreFactory TestStoreFactory
=> CosmosTestStoreFactory.Instance;

public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
=> base.AddOptions(
builder.ConfigureWarnings(w => w.Ignore(CosmosEventId.NoPartitionKeyDefined)));
=> base.AddOptions(builder)
.ConfigureWarnings(w => w.Ignore(CosmosEventId.NoPartitionKeyDefined));

public Task NoSyncTest(bool async, Func<bool, Task> testCode)
=> CosmosTestHelpers.Instance.NoSyncTest(async, testCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ namespace Microsoft.EntityFrameworkCore.Query.Relationships.OwnedNavigations;
/// </summary>
public abstract class OwnedNavigationsRelationalFixtureBase : OwnedTableSplittingRelationalFixtureBase, ITestSqlLoggerFactory
{
public override bool AreCollectionsOrdered
=> false;

protected override string StoreName
=> "OwnedNavigationsQueryTest";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ namespace Microsoft.EntityFrameworkCore.Query.Relationships.OwnedTableSplitting;
/// </summary>
public abstract class OwnedTableSplittingRelationalFixtureBase : OwnedNavigationsFixtureBase, ITestSqlLoggerFactory
{
public override bool AreCollectionsOrdered
=> false;

protected override string StoreName
=> "OwnedTableSplittingQueryTest";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@ protected override RelationshipsData CreateData()
return data;
}

// Derived fixtures may need to ignore some owned navigations that are mapped in this fixture.
public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
=> builder.ConfigureWarnings(b =>
b.Default(WarningBehavior.Ignore).Log(CoreEventId.MappedNavigationIgnoredWarning));
=> base.AddOptions(builder)
.ConfigureWarnings(b => b
// Derived fixtures may need to ignore some owned navigations that are mapped in this fixture,
.Ignore(CoreEventId.MappedNavigationIgnoredWarning)
// Cosmos (and possibly others) don't support navigations, so we remove RootReferencingType from the model
.Ignore(CoreEventId.MappedEntityTypeIgnoredWarning));
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public override async Task Index_parameter()

AssertSql(
"""
@i='?' (DbType = Int32)
@i='0'

SELECT [r].[Id], [r].[Name], [r].[OptionalRelated], [r].[RelatedCollection], [r].[RequiredRelated]
FROM [RootEntity] AS [r]
Expand Down
Loading
Loading