diff --git a/src/HotChocolate/Data/src/Data/Projections/Expressions/Handlers/QueryableProjectionFieldHandler.cs b/src/HotChocolate/Data/src/Data/Projections/Expressions/Handlers/QueryableProjectionFieldHandler.cs index 655e6cc0315..c1546a79c84 100644 --- a/src/HotChocolate/Data/src/Data/Projections/Expressions/Handlers/QueryableProjectionFieldHandler.cs +++ b/src/HotChocolate/Data/src/Data/Projections/Expressions/Handlers/QueryableProjectionFieldHandler.cs @@ -1,10 +1,12 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.Linq; using System.Linq.Expressions; using System.Reflection; using HotChocolate.Execution.Processing; using HotChocolate.Types; +using static HotChocolate.Data.Projections.Expressions.ProjectionExpressionBuilder; namespace HotChocolate.Data.Projections.Expressions.Handlers { @@ -81,16 +83,30 @@ public class QueryableProjectionFieldHandler Queue members = queryableScope.Level.Pop(); MemberInitExpression memberInit = - ProjectionExpressionBuilder.CreateMemberInit(queryableScope.RuntimeType, members); + CreateMemberInit(queryableScope.RuntimeType, members); if (!context.TryGetQueryableScope(out QueryableProjectionScope? parentScope)) { throw new InvalidOperationException(); } + Expression nestedProperty; + if (field.Member is PropertyInfo propertyInfo) + { + nestedProperty = Expression.Property(context.GetInstance(), propertyInfo); + } + else if (field.Member is MethodInfo methodInfo) + { + nestedProperty = Expression.Call(context.GetInstance(), methodInfo); + } + else + { + throw new InvalidOperationException(); + } + parentScope.Level.Peek() .Enqueue( - Expression.Bind(field.Member, memberInit)); + Expression.Bind(field.Member, NotNullAndAlso(nestedProperty, memberInit))); action = SelectionVisitor.Continue; return true; diff --git a/src/HotChocolate/Data/src/Data/Projections/Expressions/ProjectionExpressionBuilder.cs b/src/HotChocolate/Data/src/Data/Projections/Expressions/ProjectionExpressionBuilder.cs index 0cced8fe331..3c8a892dd92 100644 --- a/src/HotChocolate/Data/src/Data/Projections/Expressions/ProjectionExpressionBuilder.cs +++ b/src/HotChocolate/Data/src/Data/Projections/Expressions/ProjectionExpressionBuilder.cs @@ -6,6 +6,9 @@ namespace HotChocolate.Data.Projections.Expressions { internal static class ProjectionExpressionBuilder { + private static readonly ConstantExpression _null = + Expression.Constant(null, typeof(object)); + public static MemberInitExpression CreateMemberInit( Type type, IEnumerable expressions) @@ -13,5 +16,18 @@ internal static class ProjectionExpressionBuilder NewExpression ctor = Expression.New(type); return Expression.MemberInit(ctor, expressions); } + + public static Expression NotNull(Expression expression) + { + return Expression.NotEqual(expression, _null); + } + + public static Expression NotNullAndAlso(Expression property, Expression condition) + { + return Expression.Condition( + NotNull(property), + condition, + Expression.Default(property.Type)); + } } } diff --git a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorObjectTests.cs b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorObjectTests.cs index 03b2eeb04a3..cce2bf60683 100644 --- a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorObjectTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorObjectTests.cs @@ -114,11 +114,11 @@ public class QueryableFilterVisitorObjectTests public async Task Create_ObjectShortEqual_Expression() { // arrange - IRequestExecutor? tester = _cache.CreateSchema(_barEntities); + IRequestExecutor tester = _cache.CreateSchema(_barEntities); // act // assert - IExecutionResult? res1 = await tester.ExecuteAsync( + IExecutionResult res1 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barShort: { eq: 12}}}) " + @@ -127,7 +127,7 @@ public async Task Create_ObjectShortEqual_Expression() res1.MatchSqlSnapshot("12"); - IExecutionResult? res2 = await tester.ExecuteAsync( + IExecutionResult res2 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barShort: { eq: 13}}}) " + @@ -136,7 +136,7 @@ public async Task Create_ObjectShortEqual_Expression() res2.MatchSqlSnapshot("13"); - IExecutionResult? res3 = await tester.ExecuteAsync( + IExecutionResult res3 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barShort: { eq: null}}}) " + @@ -149,9 +149,9 @@ public async Task Create_ObjectShortEqual_Expression() [Fact] public async Task Create_ObjectShortIn_Expression() { - IRequestExecutor? tester = _cache.CreateSchema(_barEntities); + IRequestExecutor tester = _cache.CreateSchema(_barEntities); - IExecutionResult? res1 = await tester.ExecuteAsync( + IExecutionResult res1 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barShort: { in: [ 12, 13 ]}}}) " + @@ -160,7 +160,7 @@ public async Task Create_ObjectShortIn_Expression() res1.MatchSqlSnapshot("12and13"); - IExecutionResult? res2 = await tester.ExecuteAsync( + IExecutionResult res2 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barShort: { in: [ null, 14 ]}}}) " + @@ -169,7 +169,7 @@ public async Task Create_ObjectShortIn_Expression() res2.MatchSqlSnapshot("13and14"); - IExecutionResult? res3 = await tester.ExecuteAsync( + IExecutionResult res3 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barShort: { in: [ null, 14 ]}}}) " + @@ -183,12 +183,12 @@ public async Task Create_ObjectShortIn_Expression() public async Task Create_ObjectNullableShortEqual_Expression() { // arrange - IRequestExecutor? tester = + IRequestExecutor tester = _cache.CreateSchema(_barNullableEntities); // act // assert - IExecutionResult? res1 = await tester.ExecuteAsync( + IExecutionResult res1 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barShort: { eq: 12}}}) " + @@ -197,7 +197,7 @@ public async Task Create_ObjectNullableShortEqual_Expression() res1.MatchSqlSnapshot("12"); - IExecutionResult? res2 = await tester.ExecuteAsync( + IExecutionResult res2 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barShort: { eq: 13}}}) " + @@ -206,7 +206,7 @@ public async Task Create_ObjectNullableShortEqual_Expression() res2.MatchSqlSnapshot("13"); - IExecutionResult? res3 = await tester.ExecuteAsync( + IExecutionResult res3 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barShort: { eq: null}}}) " + @@ -219,10 +219,10 @@ public async Task Create_ObjectNullableShortEqual_Expression() [Fact] public async Task Create_ObjectNullableShortIn_Expression() { - IRequestExecutor? tester = + IRequestExecutor tester = _cache.CreateSchema(_barNullableEntities); - IExecutionResult? res1 = await tester.ExecuteAsync( + IExecutionResult res1 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barShort: { in: [ 12, 13 ]}}}) " + @@ -231,7 +231,7 @@ public async Task Create_ObjectNullableShortIn_Expression() res1.MatchSqlSnapshot("12and13"); - IExecutionResult? res2 = await tester.ExecuteAsync( + IExecutionResult res2 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barShort: { in: [ 13, 14 ]}}}) " + @@ -240,7 +240,7 @@ public async Task Create_ObjectNullableShortIn_Expression() res2.MatchSqlSnapshot("13and14"); - IExecutionResult? res3 = await tester.ExecuteAsync( + IExecutionResult res3 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barShort: { in: [ 13, null ]}}}) " + @@ -254,11 +254,11 @@ public async Task Create_ObjectNullableShortIn_Expression() public async Task Create_ObjectBooleanEqual_Expression() { // arrange - IRequestExecutor? tester = _cache.CreateSchema(_barEntities); + IRequestExecutor tester = _cache.CreateSchema(_barEntities); // act // assert - IExecutionResult? res1 = await tester.ExecuteAsync( + IExecutionResult res1 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barBool: { eq: true}}}) " + @@ -267,7 +267,7 @@ public async Task Create_ObjectBooleanEqual_Expression() res1.MatchSqlSnapshot("true"); - IExecutionResult? res2 = await tester.ExecuteAsync( + IExecutionResult res2 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barBool: { eq: false}}}) " + @@ -281,12 +281,12 @@ public async Task Create_ObjectBooleanEqual_Expression() public async Task Create_ObjectNullableBooleanEqual_Expression() { // arrange - IRequestExecutor? tester = _cache.CreateSchema( + IRequestExecutor tester = _cache.CreateSchema( _barNullableEntities); // act // assert - IExecutionResult? res1 = await tester.ExecuteAsync( + IExecutionResult res1 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barBool: { eq: true}}}) " + @@ -295,7 +295,7 @@ public async Task Create_ObjectNullableBooleanEqual_Expression() res1.MatchSqlSnapshot("true"); - IExecutionResult? res2 = await tester.ExecuteAsync( + IExecutionResult res2 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barBool: { eq: false}}}) " + @@ -304,7 +304,7 @@ public async Task Create_ObjectNullableBooleanEqual_Expression() res2.MatchSqlSnapshot("false"); - IExecutionResult? res3 = await tester.ExecuteAsync( + IExecutionResult res3 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barBool: { eq: null}}}) " + @@ -317,11 +317,11 @@ public async Task Create_ObjectNullableBooleanEqual_Expression() [Fact] public async Task Create_ObjectEnumEqual_Expression() { - IRequestExecutor? tester = _cache.CreateSchema(_barEntities); + IRequestExecutor tester = _cache.CreateSchema(_barEntities); // act // assert - IExecutionResult? res1 = await tester.ExecuteAsync( + IExecutionResult res1 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barEnum: { eq: BAR}}}) " + @@ -330,7 +330,7 @@ public async Task Create_ObjectEnumEqual_Expression() res1.MatchSqlSnapshot("BAR"); - IExecutionResult? res2 = await tester.ExecuteAsync( + IExecutionResult res2 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barEnum: { eq: FOO}}}) " + @@ -339,7 +339,7 @@ public async Task Create_ObjectEnumEqual_Expression() res2.MatchSqlSnapshot("FOO"); - IExecutionResult? res3 = await tester.ExecuteAsync( + IExecutionResult res3 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barEnum: { eq: null}}}) " + @@ -352,11 +352,11 @@ public async Task Create_ObjectEnumEqual_Expression() [Fact] public async Task Create_ObjectEnumIn_Expression() { - IRequestExecutor? tester = _cache.CreateSchema(_barEntities); + IRequestExecutor tester = _cache.CreateSchema(_barEntities); // act // assert - IExecutionResult? res1 = await tester.ExecuteAsync( + IExecutionResult res1 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barEnum: { in: [ BAR FOO ]}}}) " + @@ -365,7 +365,7 @@ public async Task Create_ObjectEnumIn_Expression() res1.MatchSqlSnapshot("BarAndFoo"); - IExecutionResult? res2 = await tester.ExecuteAsync( + IExecutionResult res2 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barEnum: { in: [ FOO ]}}}) " + @@ -374,7 +374,7 @@ public async Task Create_ObjectEnumIn_Expression() res2.MatchSqlSnapshot("FOO"); - IExecutionResult? res3 = await tester.ExecuteAsync( + IExecutionResult res3 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barEnum: { in: [ null FOO ]}}}) " + @@ -387,12 +387,12 @@ public async Task Create_ObjectEnumIn_Expression() [Fact] public async Task Create_ObjectNullableEnumEqual_Expression() { - IRequestExecutor? tester = _cache.CreateSchema( + IRequestExecutor tester = _cache.CreateSchema( _barNullableEntities); // act // assert - IExecutionResult? res1 = await tester.ExecuteAsync( + IExecutionResult res1 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barEnum: { eq: BAR}}}) " + @@ -401,7 +401,7 @@ public async Task Create_ObjectNullableEnumEqual_Expression() res1.MatchSqlSnapshot("BAR"); - IExecutionResult? res2 = await tester.ExecuteAsync( + IExecutionResult res2 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barEnum: { eq: FOO}}}) " + @@ -410,7 +410,7 @@ public async Task Create_ObjectNullableEnumEqual_Expression() res2.MatchSqlSnapshot("FOO"); - IExecutionResult? res3 = await tester.ExecuteAsync( + IExecutionResult res3 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barEnum: { eq: null}}}) " + @@ -423,12 +423,12 @@ public async Task Create_ObjectNullableEnumEqual_Expression() [Fact] public async Task Create_ObjectNullableEnumIn_Expression() { - IRequestExecutor? tester = _cache.CreateSchema( + IRequestExecutor tester = _cache.CreateSchema( _barNullableEntities); // act // assert - IExecutionResult? res1 = await tester.ExecuteAsync( + IExecutionResult res1 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barEnum: { in: [ BAR FOO ]}}}) " + @@ -437,7 +437,7 @@ public async Task Create_ObjectNullableEnumIn_Expression() res1.MatchSqlSnapshot("BarAndFoo"); - IExecutionResult? res2 = await tester.ExecuteAsync( + IExecutionResult res2 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barEnum: { in: [ FOO ]}}}) " + @@ -446,7 +446,7 @@ public async Task Create_ObjectNullableEnumIn_Expression() res2.MatchSqlSnapshot("FOO"); - IExecutionResult? res3 = await tester.ExecuteAsync( + IExecutionResult res3 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barEnum: { in: [ null FOO ]}}}) " + @@ -460,11 +460,11 @@ public async Task Create_ObjectNullableEnumIn_Expression() public async Task Create_ObjectStringEqual_Expression() { // arrange - IRequestExecutor? tester = _cache.CreateSchema(_barEntities); + IRequestExecutor tester = _cache.CreateSchema(_barEntities); // act // assert - IExecutionResult? res1 = await tester.ExecuteAsync( + IExecutionResult res1 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barString: { eq: \"testatest\"}}}) " + @@ -473,7 +473,7 @@ public async Task Create_ObjectStringEqual_Expression() res1.MatchSqlSnapshot("testatest"); - IExecutionResult? res2 = await tester.ExecuteAsync( + IExecutionResult res2 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barString: { eq: \"testbtest\"}}}) " + @@ -482,7 +482,7 @@ public async Task Create_ObjectStringEqual_Expression() res2.MatchSqlSnapshot("testbtest"); - IExecutionResult? res3 = await tester.ExecuteAsync( + IExecutionResult res3 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barString: { eq: null}}}){ foo{ barString}}}") @@ -495,21 +495,21 @@ public async Task Create_ObjectStringEqual_Expression() public async Task Create_ObjectStringIn_Expression() { // arrange - IRequestExecutor? tester = _cache.CreateSchema(_barEntities); + IRequestExecutor tester = _cache.CreateSchema(_barEntities); // act // assert - IExecutionResult? res1 = await tester.ExecuteAsync( + IExecutionResult res1 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( - "{ root(where: { foo: { barString: { in: " + + "{ root(where: { foo: { barString: { in: " + "[ \"testatest\" \"testbtest\" ]}}}) " + "{ foo{ barString}}}") .Create()); res1.MatchSqlSnapshot("testatestAndtestb"); - IExecutionResult? res2 = await tester.ExecuteAsync( + IExecutionResult res2 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barString: { in: [\"testbtest\" null]}}}) " + @@ -518,7 +518,7 @@ public async Task Create_ObjectStringIn_Expression() res2.MatchSqlSnapshot("testbtestAndNull"); - IExecutionResult? res3 = await tester.ExecuteAsync( + IExecutionResult res3 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { barString: { in: [ \"testatest\" ]}}}) " + @@ -532,11 +532,11 @@ public async Task Create_ObjectStringIn_Expression() public async Task Create_ArrayObjectNestedArraySomeStringEqual_Expression() { // arrange - IRequestExecutor? tester = _cache.CreateSchema(_barEntities); + IRequestExecutor tester = _cache.CreateSchema(_barEntities); // act // assert - IExecutionResult? res1 = await tester.ExecuteAsync( + IExecutionResult res1 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo:{ objectArray: { " + @@ -546,7 +546,7 @@ public async Task Create_ArrayObjectNestedArraySomeStringEqual_Expression() res1.MatchSqlSnapshot("a"); - IExecutionResult? res2 = await tester.ExecuteAsync( + IExecutionResult res2 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo:{ objectArray: { " + @@ -556,7 +556,7 @@ public async Task Create_ArrayObjectNestedArraySomeStringEqual_Expression() res2.MatchSqlSnapshot("d"); - IExecutionResult? res3 = await tester.ExecuteAsync( + IExecutionResult res3 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo:{ objectArray: { " + @@ -571,11 +571,11 @@ public async Task Create_ArrayObjectNestedArraySomeStringEqual_Expression() public async Task Create_ArrayObjectNestedArrayAnyStringEqual_Expression() { // arrange - IRequestExecutor? tester = _cache.CreateSchema(_barEntities); + IRequestExecutor tester = _cache.CreateSchema(_barEntities); // act // assert - IExecutionResult? res1 = await tester.ExecuteAsync( + IExecutionResult res1 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { objectArray: { any: false}}}) " + @@ -584,7 +584,7 @@ public async Task Create_ArrayObjectNestedArrayAnyStringEqual_Expression() res1.MatchSqlSnapshot("false"); - IExecutionResult? res2 = await tester.ExecuteAsync( + IExecutionResult res2 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { objectArray: { any: true}}}) " + @@ -593,7 +593,7 @@ public async Task Create_ArrayObjectNestedArrayAnyStringEqual_Expression() res2.MatchSqlSnapshot("true"); - IExecutionResult? res3 = await tester.ExecuteAsync( + IExecutionResult res3 = await tester.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( "{ root(where: { foo: { objectArray: { any: null}}}) " + diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionFilterTests.cs b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionFilterTests.cs index 745b62506c3..f6826cbc70c 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionFilterTests.cs +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionFilterTests.cs @@ -101,6 +101,34 @@ public class QueryableProjectionFilterTests } }; + private static readonly BarNullable[] _barWithoutRelation = + { + new BarNullable + { + Foo = new FooNullable + { + BarEnum = BarEnum.BAR, + BarShort = 15, + NestedObject = new BarNullableDeep + { + Foo = new FooDeep + { + BarString = "Foo" + } + } + } + }, + new BarNullable + { + Foo = new FooNullable + { + BarEnum = BarEnum.FOO, + BarShort = 14 + } + }, + new BarNullable() + }; + private readonly SchemaCache _cache = new SchemaCache(); [Fact] @@ -249,6 +277,87 @@ public async Task Create_ListObjectDifferentLevelProjection_Nullable() res1.MatchSqlSnapshot(); } + [Fact] + public async Task Should_NotInitializeObject_When_ResultOfLeftJoinIsNull() + { + // arrange + IRequestExecutor tester = _cache.CreateSchema(_barWithoutRelation, OnModelCreating); + + // act + // assert + IExecutionResult res1 = await tester.ExecuteAsync( + QueryRequestBuilder.New() + .SetQuery( + @" + { + root { + foo { + id + } + } + }") + .Create()); + + res1.MatchSqlSnapshot(); + } + + [Fact] + public async Task Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_TwoFields() + { + // arrange + IRequestExecutor tester = _cache.CreateSchema(_barWithoutRelation, OnModelCreating); + + // act + // assert + IExecutionResult res1 = await tester.ExecuteAsync( + QueryRequestBuilder.New() + .SetQuery( + @" + { + root { + id + foo { + id + barEnum + } + } + }") + .Create()); + + res1.MatchSqlSnapshot(); + } + + [Fact] + public async Task Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_Deep() + { + // arrange + IRequestExecutor tester = _cache.CreateSchema(_barWithoutRelation, OnModelCreating); + + // act + // assert + IExecutionResult res1 = await tester.ExecuteAsync( + QueryRequestBuilder.New() + .SetQuery( + @" + { + root { + id + foo { + id + barEnum + nestedObject { + foo { + barString + } + } + } + } + }") + .Create()); + + res1.MatchSqlSnapshot(); + } + public static void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity().HasMany(x => x.ObjectArray); diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Create_DeepFilterObjectTwoProjections_Nullable__sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Create_DeepFilterObjectTwoProjections_Nullable__sql.snap index 65bbd78b3d1..da2019933f4 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Create_DeepFilterObjectTwoProjections_Nullable__sql.snap +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Create_DeepFilterObjectTwoProjections_Nullable__sql.snap @@ -1,10 +1,10 @@ .param set @__p_0 'a' -SELECT "d"."Id", "f"."Id", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" +SELECT "f"."Id" IS NOT NULL, "d"."Id", "f"."Id", "t"."c", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" FROM "Data" AS "d" LEFT JOIN "FooNullable" AS "f" ON "d"."FooId" = "f"."Id" LEFT JOIN ( - SELECT "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooNullableId" + SELECT "f0"."Id" IS NOT NULL AS "c", "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooNullableId" FROM "BarNullableDeep" AS "b" LEFT JOIN "FooDeep" AS "f0" ON "b"."FooId" = "f0"."Id" WHERE "f0"."BarString" = @__p_0 diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Create_DeepFilterObjectTwoProjections__sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Create_DeepFilterObjectTwoProjections__sql.snap index 7bbb1cf4320..a3f55640f93 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Create_DeepFilterObjectTwoProjections__sql.snap +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Create_DeepFilterObjectTwoProjections__sql.snap @@ -1,10 +1,10 @@ .param set @__p_0 'a' -SELECT "d"."Id", "f"."Id", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" +SELECT "f"."Id" IS NOT NULL, "d"."Id", "f"."Id", "t"."c", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" FROM "Data" AS "d" LEFT JOIN "Foo" AS "f" ON "d"."FooId" = "f"."Id" LEFT JOIN ( - SELECT "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooId" + SELECT "f0"."Id" IS NOT NULL AS "c", "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooId" FROM "BarDeep" AS "b" LEFT JOIN "FooDeep" AS "f0" ON "b"."FooId1" = "f0"."Id" WHERE "f0"."BarString" = @__p_0 diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Create_ListObjectDifferentLevelProjection_Nullable__sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Create_ListObjectDifferentLevelProjection_Nullable__sql.snap index 70f3b9f273d..ae6e159952f 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Create_ListObjectDifferentLevelProjection_Nullable__sql.snap +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Create_ListObjectDifferentLevelProjection_Nullable__sql.snap @@ -1,10 +1,10 @@ .param set @__p_0 'a' -SELECT "f"."BarString", "d"."Id", "f"."Id", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" +SELECT "f"."Id" IS NOT NULL, "f"."BarString", "d"."Id", "f"."Id", "t"."c", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" FROM "Data" AS "d" LEFT JOIN "FooNullable" AS "f" ON "d"."FooId" = "f"."Id" LEFT JOIN ( - SELECT "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooNullableId" + SELECT "f0"."Id" IS NOT NULL AS "c", "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooNullableId" FROM "BarNullableDeep" AS "b" LEFT JOIN "FooDeep" AS "f0" ON "b"."FooId" = "f0"."Id" WHERE "f0"."BarString" = @__p_0 diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Create_ListObjectDifferentLevelProjection__sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Create_ListObjectDifferentLevelProjection__sql.snap index 94dd2ff6e51..374cfb331b9 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Create_ListObjectDifferentLevelProjection__sql.snap +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Create_ListObjectDifferentLevelProjection__sql.snap @@ -1,10 +1,10 @@ .param set @__p_0 'a' -SELECT "f"."BarString", "d"."Id", "f"."Id", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" +SELECT "f"."Id" IS NOT NULL, "f"."BarString", "d"."Id", "f"."Id", "t"."c", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" FROM "Data" AS "d" LEFT JOIN "Foo" AS "f" ON "d"."FooId" = "f"."Id" LEFT JOIN ( - SELECT "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooId" + SELECT "f0"."Id" IS NOT NULL AS "c", "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooId" FROM "BarDeep" AS "b" LEFT JOIN "FooDeep" AS "f0" ON "b"."FooId1" = "f0"."Id" WHERE "f0"."BarString" = @__p_0 diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ObjectSingleProjection_12.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Should_NotInitializeObject_When_ResultOfLeftJoinIsNull.snap similarity index 64% rename from src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ObjectSingleProjection_12.snap rename to src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Should_NotInitializeObject_When_ResultOfLeftJoinIsNull.snap index 43424163d38..4d98cc51578 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ObjectSingleProjection_12.snap +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Should_NotInitializeObject_When_ResultOfLeftJoinIsNull.snap @@ -1,14 +1,17 @@ { "data": { "root": [ + { + "foo": null + }, { "foo": { - "barShort": 12 + "id": 1 } }, { "foo": { - "barShort": 14 + "id": 2 } } ] diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_Deep.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_Deep.snap new file mode 100644 index 00000000000..e4950dc7c17 --- /dev/null +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_Deep.snap @@ -0,0 +1,30 @@ +{ + "data": { + "root": [ + { + "id": 1, + "foo": null + }, + { + "id": 2, + "foo": { + "id": 1, + "barEnum": "FOO", + "nestedObject": null + } + }, + { + "id": 3, + "foo": { + "id": 2, + "barEnum": "BAR", + "nestedObject": { + "foo": { + "barString": "Foo" + } + } + } + } + ] + } +} diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_Deep__sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_Deep__sql.snap new file mode 100644 index 00000000000..420cb273d6c --- /dev/null +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_Deep__sql.snap @@ -0,0 +1,5 @@ +SELECT "d"."Id", "f"."Id" IS NOT NULL, "f"."Id", "f"."BarEnum", "b"."Id" IS NOT NULL, "f0"."Id" IS NOT NULL, "f0"."BarString" +FROM "Data" AS "d" +LEFT JOIN "FooNullable" AS "f" ON "d"."FooId" = "f"."Id" +LEFT JOIN "BarNullableDeep" AS "b" ON "f"."NestedObjectId" = "b"."Id" +LEFT JOIN "FooDeep" AS "f0" ON "b"."FooId" = "f0"."Id" diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_TwoFields.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_TwoFields.snap new file mode 100644 index 00000000000..07ea2a3e473 --- /dev/null +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_TwoFields.snap @@ -0,0 +1,24 @@ +{ + "data": { + "root": [ + { + "id": 1, + "foo": null + }, + { + "id": 2, + "foo": { + "id": 1, + "barEnum": "FOO" + } + }, + { + "id": 3, + "foo": { + "id": 2, + "barEnum": "BAR" + } + } + ] + } +} diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_TwoFields__sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_TwoFields__sql.snap new file mode 100644 index 00000000000..f4c53995682 --- /dev/null +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_TwoFields__sql.snap @@ -0,0 +1,3 @@ +SELECT "d"."Id", "f"."Id" IS NOT NULL, "f"."Id", "f"."BarEnum" +FROM "Data" AS "d" +LEFT JOIN "FooNullable" AS "f" ON "d"."FooId" = "f"."Id" diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Should_NotInitializeObject_When_ResultOfLeftJoinIsNull__sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Should_NotInitializeObject_When_ResultOfLeftJoinIsNull__sql.snap new file mode 100644 index 00000000000..bb058c7a15e --- /dev/null +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionFilterTests.Should_NotInitializeObject_When_ResultOfLeftJoinIsNull__sql.snap @@ -0,0 +1,3 @@ +SELECT "f"."Id" IS NOT NULL, "f"."Id" +FROM "Data" AS "d" +LEFT JOIN "FooNullable" AS "f" ON "d"."FooId" = "f"."Id" diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionHashSetTests.Create_DeepFilterObjectTwoProjections__sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionHashSetTests.Create_DeepFilterObjectTwoProjections__sql.snap index 0cfed6b7556..aefa44218d0 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionHashSetTests.Create_DeepFilterObjectTwoProjections__sql.snap +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionHashSetTests.Create_DeepFilterObjectTwoProjections__sql.snap @@ -1,8 +1,8 @@ -SELECT "d"."Id", "f"."Id", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" +SELECT "f"."Id" IS NOT NULL, "d"."Id", "f"."Id", "t"."c", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" FROM "Data" AS "d" LEFT JOIN "Foo" AS "f" ON "d"."FooId" = "f"."Id" LEFT JOIN ( - SELECT "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooId" + SELECT "f0"."Id" IS NOT NULL AS "c", "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooId" FROM "BarDeep" AS "b" LEFT JOIN "FooDeep" AS "f0" ON "b"."FooId1" = "f0"."Id" ) AS "t" ON "f"."Id" = "t"."FooId" diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionHashSetTests.Create_ListObjectDifferentLevelProjection__sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionHashSetTests.Create_ListObjectDifferentLevelProjection__sql.snap index eecc8239c45..088436aec98 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionHashSetTests.Create_ListObjectDifferentLevelProjection__sql.snap +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionHashSetTests.Create_ListObjectDifferentLevelProjection__sql.snap @@ -1,8 +1,8 @@ -SELECT "f"."BarString", "d"."Id", "f"."Id", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" +SELECT "f"."Id" IS NOT NULL, "f"."BarString", "d"."Id", "f"."Id", "t"."c", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" FROM "Data" AS "d" LEFT JOIN "Foo" AS "f" ON "d"."FooId" = "f"."Id" LEFT JOIN ( - SELECT "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooId" + SELECT "f0"."Id" IS NOT NULL AS "c", "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooId" FROM "BarDeep" AS "b" LEFT JOIN "FooDeep" AS "f0" ON "b"."FooId1" = "f0"."Id" ) AS "t" ON "f"."Id" = "t"."FooId" diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionISetTests.Create_DeepFilterObjectTwoProjections__sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionISetTests.Create_DeepFilterObjectTwoProjections__sql.snap index 0cfed6b7556..aefa44218d0 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionISetTests.Create_DeepFilterObjectTwoProjections__sql.snap +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionISetTests.Create_DeepFilterObjectTwoProjections__sql.snap @@ -1,8 +1,8 @@ -SELECT "d"."Id", "f"."Id", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" +SELECT "f"."Id" IS NOT NULL, "d"."Id", "f"."Id", "t"."c", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" FROM "Data" AS "d" LEFT JOIN "Foo" AS "f" ON "d"."FooId" = "f"."Id" LEFT JOIN ( - SELECT "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooId" + SELECT "f0"."Id" IS NOT NULL AS "c", "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooId" FROM "BarDeep" AS "b" LEFT JOIN "FooDeep" AS "f0" ON "b"."FooId1" = "f0"."Id" ) AS "t" ON "f"."Id" = "t"."FooId" diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionISetTests.Create_ListObjectDifferentLevelProjection__sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionISetTests.Create_ListObjectDifferentLevelProjection__sql.snap index eecc8239c45..088436aec98 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionISetTests.Create_ListObjectDifferentLevelProjection__sql.snap +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionISetTests.Create_ListObjectDifferentLevelProjection__sql.snap @@ -1,8 +1,8 @@ -SELECT "f"."BarString", "d"."Id", "f"."Id", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" +SELECT "f"."Id" IS NOT NULL, "f"."BarString", "d"."Id", "f"."Id", "t"."c", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" FROM "Data" AS "d" LEFT JOIN "Foo" AS "f" ON "d"."FooId" = "f"."Id" LEFT JOIN ( - SELECT "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooId" + SELECT "f0"."Id" IS NOT NULL AS "c", "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooId" FROM "BarDeep" AS "b" LEFT JOIN "FooDeep" AS "f0" ON "b"."FooId1" = "f0"."Id" ) AS "t" ON "f"."Id" = "t"."FooId" diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionSortedSetTests.Create_DeepFilterObjectTwoProjections__sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionSortedSetTests.Create_DeepFilterObjectTwoProjections__sql.snap index 0cfed6b7556..aefa44218d0 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionSortedSetTests.Create_DeepFilterObjectTwoProjections__sql.snap +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionSortedSetTests.Create_DeepFilterObjectTwoProjections__sql.snap @@ -1,8 +1,8 @@ -SELECT "d"."Id", "f"."Id", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" +SELECT "f"."Id" IS NOT NULL, "d"."Id", "f"."Id", "t"."c", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" FROM "Data" AS "d" LEFT JOIN "Foo" AS "f" ON "d"."FooId" = "f"."Id" LEFT JOIN ( - SELECT "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooId" + SELECT "f0"."Id" IS NOT NULL AS "c", "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooId" FROM "BarDeep" AS "b" LEFT JOIN "FooDeep" AS "f0" ON "b"."FooId1" = "f0"."Id" ) AS "t" ON "f"."Id" = "t"."FooId" diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionSortedSetTests.Create_ListObjectDifferentLevelProjection__sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionSortedSetTests.Create_ListObjectDifferentLevelProjection__sql.snap index eecc8239c45..088436aec98 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionSortedSetTests.Create_ListObjectDifferentLevelProjection__sql.snap +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionSortedSetTests.Create_ListObjectDifferentLevelProjection__sql.snap @@ -1,8 +1,8 @@ -SELECT "f"."BarString", "d"."Id", "f"."Id", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" +SELECT "f"."Id" IS NOT NULL, "f"."BarString", "d"."Id", "f"."Id", "t"."c", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" FROM "Data" AS "d" LEFT JOIN "Foo" AS "f" ON "d"."FooId" = "f"."Id" LEFT JOIN ( - SELECT "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooId" + SELECT "f0"."Id" IS NOT NULL AS "c", "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooId" FROM "BarDeep" AS "b" LEFT JOIN "FooDeep" AS "f0" ON "b"."FooId1" = "f0"."Id" ) AS "t" ON "f"."Id" = "t"."FooId" diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionSortingTests.Create_DeepFilterObjectTwoProjections__sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionSortingTests.Create_DeepFilterObjectTwoProjections__sql.snap index afa6a72170e..f8ec21aed1b 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionSortingTests.Create_DeepFilterObjectTwoProjections__sql.snap +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionSortingTests.Create_DeepFilterObjectTwoProjections__sql.snap @@ -1,8 +1,8 @@ -SELECT "d"."Id", "f"."Id", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" +SELECT "f"."Id" IS NOT NULL, "d"."Id", "f"."Id", "t"."c", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" FROM "Data" AS "d" LEFT JOIN "Foo" AS "f" ON "d"."FooId" = "f"."Id" LEFT JOIN ( - SELECT "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooId" + SELECT "f0"."Id" IS NOT NULL AS "c", "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooId" FROM "BarDeep" AS "b" LEFT JOIN "FooDeep" AS "f0" ON "b"."FooId1" = "f0"."Id" ) AS "t" ON "f"."Id" = "t"."FooId" diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionSortingTests.Create_ListObjectDifferentLevelProjection__sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionSortingTests.Create_ListObjectDifferentLevelProjection__sql.snap index 903d09f6b8d..84f3705302e 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionSortingTests.Create_ListObjectDifferentLevelProjection__sql.snap +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionSortingTests.Create_ListObjectDifferentLevelProjection__sql.snap @@ -1,8 +1,8 @@ -SELECT "f"."BarString", "d"."Id", "f"."Id", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" +SELECT "f"."Id" IS NOT NULL, "f"."BarString", "d"."Id", "f"."Id", "t"."c", "t"."BarString", "t"."BarShort", "t"."Id", "t"."Id0" FROM "Data" AS "d" LEFT JOIN "Foo" AS "f" ON "d"."FooId" = "f"."Id" LEFT JOIN ( - SELECT "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooId" + SELECT "f0"."Id" IS NOT NULL AS "c", "f0"."BarString", "f0"."BarShort", "b"."Id", "f0"."Id" AS "Id0", "b"."FooId" FROM "BarDeep" AS "b" LEFT JOIN "FooDeep" AS "f0" ON "b"."FooId1" = "f0"."Id" ) AS "t" ON "f"."Id" = "t"."FooId" diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ListObjectDifferentLevelProjection_12.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ListObjectDifferentLevelProjection_12.snap deleted file mode 100644 index b57a86b8336..00000000000 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ListObjectDifferentLevelProjection_12.snap +++ /dev/null @@ -1,30 +0,0 @@ -{ - "data": { - "root": [ - { - "foo": { - "barString": "testatest", - "objectArray": [ - { - "foo": { - "barShort": 12 - } - } - ] - } - }, - { - "foo": { - "barString": "testbtest", - "objectArray": [ - { - "foo": { - "barShort": 14 - } - } - ] - } - } - ] - } -} diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ListObjectDifferentLevelProjection_12_sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ListObjectDifferentLevelProjection_12_sql.snap deleted file mode 100644 index b83d72a59f7..00000000000 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ListObjectDifferentLevelProjection_12_sql.snap +++ /dev/null @@ -1,9 +0,0 @@ -SELECT "f"."BarString", "d"."Id", "t"."BarShort", "t"."Id" -FROM "Data" AS "d" -LEFT JOIN "Foo" AS "f" ON "d"."FooId" = "f"."Id" -LEFT JOIN ( - SELECT "f0"."BarShort", "b"."Id", "b"."FooId" - FROM "BarDeep" AS "b" - LEFT JOIN "FooDeep" AS "f0" ON "b"."FooId1" = "f0"."Id" -) AS "t" ON "f"."Id" = "t"."FooId" -ORDER BY "d"."Id", "t"."Id" diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ListObjectTwoProjections_12.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ListObjectTwoProjections_12.snap deleted file mode 100644 index 3452a3126d1..00000000000 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ListObjectTwoProjections_12.snap +++ /dev/null @@ -1,30 +0,0 @@ -{ - "data": { - "root": [ - { - "foo": { - "objectArray": [ - { - "foo": { - "barString": "a", - "barShort": 12 - } - } - ] - } - }, - { - "foo": { - "objectArray": [ - { - "foo": { - "barString": "d", - "barShort": 14 - } - } - ] - } - } - ] - } -} diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ListObjectTwoProjections_12_sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ListObjectTwoProjections_12_sql.snap deleted file mode 100644 index d05266c20ca..00000000000 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ListObjectTwoProjections_12_sql.snap +++ /dev/null @@ -1,9 +0,0 @@ -SELECT "d"."Id", "t"."BarString", "t"."BarShort", "t"."Id" -FROM "Data" AS "d" -LEFT JOIN "Foo" AS "f" ON "d"."FooId" = "f"."Id" -LEFT JOIN ( - SELECT "f0"."BarString", "f0"."BarShort", "b"."Id", "b"."FooId" - FROM "BarDeep" AS "b" - LEFT JOIN "FooDeep" AS "f0" ON "b"."FooId1" = "f0"."Id" -) AS "t" ON "f"."Id" = "t"."FooId" -ORDER BY "d"."Id", "t"."Id" diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_NestedObjectDifferentLevelProjection_12.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_NestedObjectDifferentLevelProjection_12.snap deleted file mode 100644 index 1de85d62620..00000000000 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_NestedObjectDifferentLevelProjection_12.snap +++ /dev/null @@ -1,26 +0,0 @@ -{ - "data": { - "root": [ - { - "foo": { - "barString": "testatest", - "nestedObject": { - "foo": { - "barShort": 12 - } - } - } - }, - { - "foo": { - "barString": "testbtest", - "nestedObject": { - "foo": { - "barShort": 12 - } - } - } - } - ] - } -} diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_NestedObjectDifferentLevelProjection_12_sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_NestedObjectDifferentLevelProjection_12_sql.snap deleted file mode 100644 index b657b841a83..00000000000 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_NestedObjectDifferentLevelProjection_12_sql.snap +++ /dev/null @@ -1,5 +0,0 @@ -SELECT "f"."BarString", "f0"."BarShort" -FROM "Data" AS "d" -LEFT JOIN "Foo" AS "f" ON "d"."FooId" = "f"."Id" -LEFT JOIN "BarDeep" AS "b" ON "f"."NestedObjectId" = "b"."Id" -LEFT JOIN "FooDeep" AS "f0" ON "b"."FooId1" = "f0"."Id" diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_NestedObjectTwoProjections_12.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_NestedObjectTwoProjections_12.snap deleted file mode 100644 index 6b1186f64b8..00000000000 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_NestedObjectTwoProjections_12.snap +++ /dev/null @@ -1,26 +0,0 @@ -{ - "data": { - "root": [ - { - "foo": { - "nestedObject": { - "foo": { - "barString": "a", - "barShort": 12 - } - } - } - }, - { - "foo": { - "nestedObject": { - "foo": { - "barString": "d", - "barShort": 12 - } - } - } - } - ] - } -} diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_NestedObjectTwoProjections_12_sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_NestedObjectTwoProjections_12_sql.snap deleted file mode 100644 index 6964b087782..00000000000 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_NestedObjectTwoProjections_12_sql.snap +++ /dev/null @@ -1,5 +0,0 @@ -SELECT "f0"."BarString", "f0"."BarShort" -FROM "Data" AS "d" -LEFT JOIN "Foo" AS "f" ON "d"."FooId" = "f"."Id" -LEFT JOIN "BarDeep" AS "b" ON "f"."NestedObjectId" = "b"."Id" -LEFT JOIN "FooDeep" AS "f0" ON "b"."FooId1" = "f0"."Id" diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ObjectSingleProjection_12_sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ObjectSingleProjection_12_sql.snap deleted file mode 100644 index b3f3591c468..00000000000 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ObjectSingleProjection_12_sql.snap +++ /dev/null @@ -1,3 +0,0 @@ -SELECT "f"."BarShort" -FROM "Data" AS "d" -LEFT JOIN "Foo" AS "f" ON "d"."FooId" = "f"."Id" diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ObjectTwoProjections_12.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ObjectTwoProjections_12.snap deleted file mode 100644 index f94ec328806..00000000000 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ObjectTwoProjections_12.snap +++ /dev/null @@ -1,18 +0,0 @@ -{ - "data": { - "root": [ - { - "foo": { - "barString": "testatest", - "barShort": 12 - } - }, - { - "foo": { - "barString": "testbtest", - "barShort": 14 - } - } - ] - } -} diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ObjectTwoProjections_12_sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ObjectTwoProjections_12_sql.snap deleted file mode 100644 index 06e0b2338d2..00000000000 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorObjectTests.Create_ObjectTwoProjections_12_sql.snap +++ /dev/null @@ -1,3 +0,0 @@ -SELECT "f"."BarString", "f"."BarShort" -FROM "Data" AS "d" -LEFT JOIN "Foo" AS "f" ON "d"."FooId" = "f"."Id" diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorPagingTests.CreateOffsetPaging_Projection_Should_Stop_When_UsePagingEncountered__sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorPagingTests.CreateOffsetPaging_Projection_Should_Stop_When_UsePagingEncountered__sql.snap index c56a9350b96..778d8ed622d 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorPagingTests.CreateOffsetPaging_Projection_Should_Stop_When_UsePagingEncountered__sql.snap +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorPagingTests.CreateOffsetPaging_Projection_Should_Stop_When_UsePagingEncountered__sql.snap @@ -1,2 +1,4 @@ -SELECT "d"."Bar" +SELECT "d"."Bar", "d"."Id", "b"."Id", "b"."BarBaz", "b"."BarQux", "b"."FooId", "b"."FooId1" FROM "Data" AS "d" +LEFT JOIN "Bar" AS "b" ON "d"."Id" = "b"."FooId1" +ORDER BY "d"."Id", "b"."Id" diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorPagingTests.Create_Projection_Should_Stop_When_UsePagingEncountered__sql.snap b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorPagingTests.Create_Projection_Should_Stop_When_UsePagingEncountered__sql.snap index c56a9350b96..778d8ed622d 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorPagingTests.Create_Projection_Should_Stop_When_UsePagingEncountered__sql.snap +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/__snapshots__/QueryableProjectionVisitorPagingTests.Create_Projection_Should_Stop_When_UsePagingEncountered__sql.snap @@ -1,2 +1,4 @@ -SELECT "d"."Bar" +SELECT "d"."Bar", "d"."Id", "b"."Id", "b"."BarBaz", "b"."BarQux", "b"."FooId", "b"."FooId1" FROM "Data" AS "d" +LEFT JOIN "Bar" AS "b" ON "d"."Id" = "b"."FooId1" +ORDER BY "d"."Id", "b"."Id"