Skip to content

Commit ea91c4c

Browse files
Shay RojanskyCopilot
andcommitted
Sync to EF 11.0.0-preview.5.26251.112
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent dda4c32 commit ea91c4c

17 files changed

Lines changed: 55 additions & 46 deletions

Directory.Packages.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project>
22
<PropertyGroup>
3-
<EFCoreVersion>11.0.0-preview.5.26227.124</EFCoreVersion>
4-
<MicrosoftExtensionsVersion>11.0.0-preview.5.26227.124</MicrosoftExtensionsVersion>
5-
<MicrosoftExtensionsConfigurationVersion>11.0.0-preview.5.26227.124</MicrosoftExtensionsConfigurationVersion>
3+
<EFCoreVersion>11.0.0-preview.5.26251.112</EFCoreVersion>
4+
<MicrosoftExtensionsVersion>11.0.0-preview.5.26251.112</MicrosoftExtensionsVersion>
5+
<MicrosoftExtensionsConfigurationVersion>11.0.0-preview.5.26251.112</MicrosoftExtensionsConfigurationVersion>
66
<NpgsqlVersion>10.0.0</NpgsqlVersion>
77
</PropertyGroup>
88

src/EFCore.PG.NodaTime/Query/Internal/NpgsqlNodaTimeMemberTranslatorPlugin.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ SqlExpression Upper()
193193
=> _sqlExpressionFactory.Convert(
194194
_sqlExpressionFactory.Subtract(
195195
Upper(),
196-
_sqlExpressionFactory.Constant(Period.FromDays(1), _periodTypeMapping)), typeof(LocalDate),
196+
_sqlExpressionFactory.Constant(Period.FromDays(1), _periodTypeMapping),
197+
_typeMappingSource.FindMapping(typeof(LocalDateTime))), typeof(LocalDate),
197198
_typeMappingSource.FindMapping(typeof(LocalDate))),
198199

199200
nameof(DateInterval.Length) => _sqlExpressionFactory.Subtract(Upper(), Lower()),

src/EFCore.PG/Query/Internal/NpgsqlQuerySqlGenerator.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,14 @@ protected virtual Expression VisitArrayAny(PgAnyExpression expression)
889889

890890
Visit(expression.Array);
891891

892+
// When the array operand is a scalar subquery, PostgreSQL interprets = ANY(subquery) as a subquery comparison
893+
// (comparing against each row), not as an array comparison. We need to add an explicit cast to force
894+
// PostgreSQL to treat it as an array expression (see #1803).
895+
if (expression.Array is ScalarSubqueryExpression { TypeMapping.StoreType: var storeType })
896+
{
897+
Sql.Append("::").Append(storeType);
898+
}
899+
892900
Sql.Append(")");
893901

894902
return expression;

src/EFCore.PG/Query/Internal/NpgsqlQueryableMethodTranslatingExpressionVisitor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -719,14 +719,14 @@ SqlConstantExpression or PgNewArrayExpression
719719

720720
// Similar to ParameterExpression below, but when a bare subquery is present inside ANY(), PostgreSQL just compares
721721
// against each of its resulting rows (just like IN). To "extract" the array result of the scalar subquery, we need
722-
// to add an explicit cast (see #1803).
722+
// to add an explicit cast (see #1803). This is handled in the SQL generator (VisitArrayAny) rather than via
723+
// SqlUnaryExpression(Convert), since it's a same-type cast that would be removed by EF's simplifier.
723724
ScalarSubqueryExpression subqueryExpression
724725
=> BuildSimplifiedShapedQuery(
725726
source,
726727
_sqlExpressionFactory.Any(
727728
translatedItem,
728-
_sqlExpressionFactory.Convert(
729-
subqueryExpression, subqueryExpression.Type, subqueryExpression.TypeMapping),
729+
subqueryExpression,
730730
PgAnyOperatorType.Equal)),
731731

732732
// For ParameterExpression, and for all other cases - e.g. array returned from some function -

src/EFCore.PG/Query/NpgsqlSqlExpressionFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ private SqlBinaryExpression ApplyTypeMappingOnSqlBinary(SqlBinaryExpression bina
447447
{
448448
var newLeft = ApplyTypeMapping(left, typeMapping);
449449
var newRight = ApplyDefaultTypeMapping(right);
450-
return new SqlBinaryExpression(binary.OperatorType, newLeft, newRight, binary.Type, newLeft.TypeMapping);
450+
return new SqlBinaryExpression(binary.OperatorType, newLeft, newRight, binary.Type, typeMapping ?? newLeft.TypeMapping);
451451
}
452452

453453
// DateTime - DateTime => TimeSpan

src/EFCore.PG/Update/Internal/NpgsqlUpdateSqlGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ protected override void AppendUpdateColumnValue(
166166

167167
if (segment.IsArray)
168168
{
169-
stringBuilder.Append(jsonPath.Ordinals[ordinalIndex++]);
169+
stringBuilder.Append(jsonPath.Indices[ordinalIndex++]);
170170
}
171171
else
172172
{

test/EFCore.PG.FunctionalTests/Query/GearsOfWarQueryNpgsqlTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ await AssertQuery(
5050
5151
SELECT m."Id", m."CodeName", m."Date", m."Difficulty", m."Duration", m."Rating", m."Time", m."Timeline"
5252
FROM "Missions" AS m
53-
WHERE date_trunc('day', m."Timeline" AT TIME ZONE 'UTC')::timestamp >= @dateTimeOffset_Date
53+
WHERE date_trunc('day', m."Timeline" AT TIME ZONE 'UTC') >= @dateTimeOffset_Date
5454
""");
5555
}
5656

test/EFCore.PG.FunctionalTests/Query/Inheritance/TPCGearsOfWarQueryNpgsqlTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ await AssertQuery(
6464
6565
SELECT m."Id", m."CodeName", m."Date", m."Difficulty", m."Duration", m."Rating", m."Time", m."Timeline"
6666
FROM "Missions" AS m
67-
WHERE date_trunc('day', m."Timeline" AT TIME ZONE 'UTC')::timestamp >= @dateTimeOffset_Date
67+
WHERE date_trunc('day', m."Timeline" AT TIME ZONE 'UTC') >= @dateTimeOffset_Date
6868
""");
6969
}
7070

test/EFCore.PG.FunctionalTests/Query/Inheritance/TPTGearsOfWarQueryNpgsqlTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ await AssertQuery(
6868
6969
SELECT m."Id", m."CodeName", m."Date", m."Difficulty", m."Duration", m."Rating", m."Time", m."Timeline"
7070
FROM "Missions" AS m
71-
WHERE date_trunc('day', m."Timeline" AT TIME ZONE 'UTC')::timestamp >= @dateTimeOffset_Date
71+
WHERE date_trunc('day', m."Timeline" AT TIME ZONE 'UTC') >= @dateTimeOffset_Date
7272
""");
7373
}
7474

test/EFCore.PG.FunctionalTests/Query/NorthwindSqlQueryNpgsqlTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ public override async Task SqlQuery_composed_Join(bool async)
4343

4444
AssertSql(
4545
"""
46-
SELECT o."OrderID", o."CustomerID", o."EmployeeID", o."OrderDate", s."Value"::int AS p
46+
SELECT o."OrderID", o."CustomerID", o."EmployeeID", o."OrderDate", s."Value" AS p
4747
FROM "Orders" AS o
4848
INNER JOIN (
4949
SELECT "ProductID" AS "Value" FROM "Products"
50-
) AS s ON o."OrderID" = s."Value"::int
50+
) AS s ON o."OrderID" = s."Value"
5151
""");
5252
}
5353

0 commit comments

Comments
 (0)