Commit 4185501
authored
[release/9.0-staging] Fix to #35393 - GroupJoin in EF Core 9 Returns Null for Joined Entities
Fixes #35393
Description
In EF9 we refactored some optimizations we performed on generated SQL - we are now applying them earlier (as part of SqlExpressionFactory. However, one of those optimizations is only correct for non-nullable arguments, and at the time we apply them we don't have full nullability information. Fix is to only apply this optimization when we know the argument is non-nullable.
Customer impact
Data corruption. Queries comparing nullable boolean property to a constant (true/false) produced incorrect results (data corruption). Workaround is to rewrite the query to add missing null checks, but this is not intuitive at all.
How found
Customer report on 9.0.0
Regression
Yes, from 8.0.
Testing
Added tests for the scenarios affected as well as test that brute-forces all combinations of comparisons between nullable arguments in variety of scenarios.
Risk
Low, we are just removing the optimization that was incorrect. After removal, the queries produced are the same as in EF8. Quirk added, just in case.1 parent cc16006 commit 4185501
File tree
13 files changed
+1860
-282
lines changed- src/EFCore.Relational/Query
- test
- EFCore.Relational.Specification.Tests/Query
- EFCore.Specification.Tests/Query
- EFCore.SqlServer.FunctionalTests/Query
- EFCore.Sqlite.FunctionalTests/Query
13 files changed
+1860
-282
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| |||
660 | 663 | | |
661 | 664 | | |
662 | 665 | | |
663 | | - | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
664 | 669 | | |
665 | 670 | | |
666 | 671 | | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
667 | 683 | | |
668 | 684 | | |
669 | 685 | | |
670 | 686 | | |
671 | 687 | | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
672 | 699 | | |
673 | 700 | | |
674 | 701 | | |
675 | 702 | | |
676 | 703 | | |
| 704 | + | |
677 | 705 | | |
678 | 706 | | |
679 | 707 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
| |||
1343 | 1346 | | |
1344 | 1347 | | |
1345 | 1348 | | |
1346 | | - | |
| 1349 | + | |
1347 | 1350 | | |
1348 | 1351 | | |
1349 | 1352 | | |
| |||
Lines changed: 53 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
102 | | - | |
| 103 | + | |
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
106 | | - | |
| 107 | + | |
107 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
108 | 112 | | |
109 | 113 | | |
110 | | - | |
| 114 | + | |
111 | 115 | | |
112 | 116 | | |
113 | 117 | | |
| |||
116 | 120 | | |
117 | 121 | | |
118 | 122 | | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
129 | 142 | | |
130 | 143 | | |
131 | 144 | | |
132 | 145 | | |
133 | 146 | | |
134 | 147 | | |
135 | 148 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
143 | 164 | | |
144 | 165 | | |
145 | 166 | | |
| |||
2462 | 2483 | | |
2463 | 2484 | | |
2464 | 2485 | | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
2465 | 2498 | | |
2466 | 2499 | | |
2467 | 2500 | | |
| |||
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
654 | 654 | | |
655 | 655 | | |
656 | 656 | | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
657 | 675 | | |
658 | 676 | | |
659 | 677 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5021 | 5021 | | |
5022 | 5022 | | |
5023 | 5023 | | |
5024 | | - | |
| 5024 | + | |
5025 | 5025 | | |
5026 | 5026 | | |
5027 | 5027 | | |
| |||
5038 | 5038 | | |
5039 | 5039 | | |
5040 | 5040 | | |
5041 | | - | |
| 5041 | + | |
5042 | 5042 | | |
5043 | 5043 | | |
5044 | 5044 | | |
| |||
7592 | 7592 | | |
7593 | 7593 | | |
7594 | 7594 | | |
7595 | | - | |
| 7595 | + | |
7596 | 7596 | | |
7597 | 7597 | | |
7598 | 7598 | | |
| |||
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
992 | 992 | | |
993 | 993 | | |
994 | 994 | | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
995 | 1011 | | |
996 | 1012 | | |
997 | 1013 | | |
| |||
0 commit comments