Skip to content

Commit

Permalink
Sync to EF 9.0.0-preview.1.24081.2 (#3089)
Browse files Browse the repository at this point in the history
  • Loading branch information
roji authored Feb 11, 2024
1 parent 35f0fd5 commit 2403c06
Show file tree
Hide file tree
Showing 56 changed files with 2,044 additions and 1,493 deletions.
10 changes: 5 additions & 5 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<EFCoreVersion>8.0.0</EFCoreVersion>
<MicrosoftExtensionsVersion>8.0.0</MicrosoftExtensionsVersion>
<NpgsqlVersion>8.0.0</NpgsqlVersion>
<EFCoreVersion>9.0.0-preview.1.24081.2</EFCoreVersion>
<MicrosoftExtensionsVersion>9.0.0-preview.1.24080.9</MicrosoftExtensionsVersion>
<NpgsqlVersion>8.0.2</NpgsqlVersion>
</PropertyGroup>

<ItemGroup>
Expand All @@ -23,8 +23,8 @@

<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="xunit" Version="2.4.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.4" />
<PackageVersion Include="xunit" Version="2.6.6" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.6" />
<PackageVersion Include="GitHubActionsTestLogger" Version="2.3.3" />
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions EFCore.PG.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EJavaScript_002ECodeStyle_002ESettingsUpgrade_002EJsParsFormattingSettingsUpgrader/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EJavaScript_002ECodeStyle_002ESettingsUpgrade_002EJsWrapperSettingsUpgrader/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EXml_002ECodeStyle_002EFormatSettingsUpgrade_002EXmlMoveToCommonFormatterSettingsUpgrade/@EntryIndexedValue">True</s:Boolean>
<<<<<<< HEAD
<s:Boolean x:Key="/Default/UserDictionary/Words/=annotatable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=annotatables/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=autoscale/@EntryIndexedValue">True</s:Boolean>
Expand Down Expand Up @@ -391,3 +392,6 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unlogged/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=utcnow/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Xunit/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ints/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ordinality/@EntryIndexedValue">True</s:Boolean>
</wpf:ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query.Expressions.Internal;
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </para>
/// </remarks>
public class PgTableValuedFunctionExpression : TableValuedFunctionExpression,
IEquatable<PgTableValuedFunctionExpression>, IClonableTableExpressionBase
public class PgTableValuedFunctionExpression : TableValuedFunctionExpression, IEquatable<PgTableValuedFunctionExpression>
{
/// <summary>
/// The name of the column to be projected out from the <c>unnest</c> call.
Expand Down Expand Up @@ -77,15 +76,25 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public override PgTableValuedFunctionExpression Update(IReadOnlyList<SqlExpression> arguments)
=> !arguments.SequenceEqual(Arguments)
? new PgTableValuedFunctionExpression(Alias, Name, arguments, ColumnInfos, WithOrdinality)
: this;
=> arguments.SequenceEqual(Arguments, ReferenceEqualityComparer.Instance)
? this
: new PgTableValuedFunctionExpression(Alias, Name, arguments, ColumnInfos, WithOrdinality);

/// <inheritdoc />
public override TableExpressionBase Clone(string? alias, ExpressionVisitor cloningExpressionVisitor)
{
var arguments = new SqlExpression[Arguments.Count];
for (var i = 0; i < arguments.Length; i++)
{
arguments[i] = (SqlExpression)cloningExpressionVisitor.Visit(Arguments[i]);
}

return new PgTableValuedFunctionExpression(Alias, Name, arguments, ColumnInfos, WithOrdinality);
}

// TODO: This is a hack for https://github.com/npgsql/efcore.pg/issues/3023; we notably don't visit the arguments, which we should
// (but can't, since the Clone() API doesn't accept the cloning visitor).
/// <inheritdoc />
public TableExpressionBase Clone()
=> new PgTableValuedFunctionExpression(Alias, Name, Arguments, ColumnInfos, WithOrdinality);
public override PgTableValuedFunctionExpression WithAlias(string newAlias)
=> new(newAlias, Name, Arguments, ColumnInfos, WithOrdinality);

/// <inheritdoc />
protected override void Print(ExpressionPrinter expressionPrinter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,12 @@ public virtual PgUnnestExpression Update(SqlExpression array)
=> array == Array
? this
: new PgUnnestExpression(Alias, array, ColumnName, WithOrdinality);

/// <inheritdoc />
public override TableExpressionBase Clone(string? alias, ExpressionVisitor cloningExpressionVisitor)
=> new PgUnnestExpression(alias!, (SqlExpression)cloningExpressionVisitor.Visit(Array), ColumnName, WithOrdinality);

/// <inheritdoc />
public override PgTableValuedFunctionExpression WithAlias(string newAlias)
=> new(newAlias, Name, Arguments, ColumnInfos, WithOrdinality);
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ protected virtual Expression VisitDelete(DeleteExpression deleteExpression)
switch (tableBase)
{
case TableExpression tableExpression:
if (tableExpression != deleteExpression.Table)
if (tableExpression.Alias != deleteExpression.Table.Alias)
{
fromItems.Add(tableExpression);
}

break;

case InnerJoinExpression { Table: { } tableExpression } innerJoinExpression:
if (tableExpression != deleteExpression.Table)
if (tableExpression.Alias != deleteExpression.Table.Alias)
{
fromItems.Add(tableExpression);
}
Expand Down
9 changes: 7 additions & 2 deletions src/EFCore.PG/Query/Internal/NpgsqlQuerySqlGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,11 @@ protected override Expression VisitValues(ValuesExpression valuesExpression)
/// </summary>
protected override void GenerateValues(ValuesExpression valuesExpression)
{
if (valuesExpression.RowValues.Count == 0)
{
throw new InvalidOperationException(RelationalStrings.EmptyCollectionNotSupportedAsInlineQueryRoot);
}

// PostgreSQL supports providing the names of columns projected out of VALUES: (VALUES (1, 3), (2, 4)) AS x(a, b).
// But since other databases sometimes don't, the default relational implementation is complex, involving a SELECT for the first row
// and a UNION All on the rest. Override to do the nice simple thing.
Expand Down Expand Up @@ -1540,8 +1545,8 @@ public bool ContainsReferenceToMainTable(SqlExpression sqlExpression)
return expression;
}

if (expression is ColumnExpression columnExpression
&& columnExpression.Table == mainTable)
if (expression is ColumnExpression { TableAlias: var tableAlias }
&& tableAlias == mainTable.Alias)
{
_containsReference = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class NpgsqlQueryTranslationPostprocessor : RelationalQueryTranslationPos
public NpgsqlQueryTranslationPostprocessor(
QueryTranslationPostprocessorDependencies dependencies,
RelationalQueryTranslationPostprocessorDependencies relationalDependencies,
QueryCompilationContext queryCompilationContext)
RelationalQueryCompilationContext queryCompilationContext)
: base(dependencies, relationalDependencies, queryCompilationContext)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@ public NpgsqlQueryTranslationPostprocessorFactory(

/// <inheritdoc />
public virtual QueryTranslationPostprocessor Create(QueryCompilationContext queryCompilationContext)
=> new NpgsqlQueryTranslationPostprocessor(Dependencies, RelationalDependencies, queryCompilationContext);
=> new NpgsqlQueryTranslationPostprocessor(
Dependencies,
RelationalDependencies,
(RelationalQueryCompilationContext)queryCompilationContext);
}
Loading

0 comments on commit 2403c06

Please sign in to comment.