未验证 提交 0fc89f24 编写于 作者: S Shay Rojansky 提交者: GitHub

Sync dependencies (#2209)

EF Core -> 7.0.0-alpha.1.22058.1
Npgsql -> 7.0.0-preview.1-ci.20220109T124254
上级 f6e9789f
<Project>
<PropertyGroup>
<EFCoreVersion>6.0.0</EFCoreVersion>
<MicrosoftExtensionsVersion>6.0.0</MicrosoftExtensionsVersion>
<NpgsqlVersion>7.0.0-preview.1-ci.20211203T135215</NpgsqlVersion>
<EFCoreVersion>7.0.0-alpha.1.22058.1</EFCoreVersion>
<MicrosoftExtensionsVersion>7.0.0-alpha.1.22052.8</MicrosoftExtensionsVersion>
<NpgsqlVersion>7.0.0-preview.1-ci.20220109T124254</NpgsqlVersion>
</PropertyGroup>
<ItemGroup>
......@@ -22,7 +22,7 @@
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageVersion Include="xunit" Version="2.4.1" />
<PackageVersion Include="xunit" Version="2.4.2-pre.9" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageVersion Include="GitHubActionsTestLogger" Version="1.2.0" />
</ItemGroup>
......
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="dotnet7" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json" />
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
<add key="npgsql-vnext" value="https://www.myget.org/F/npgsql-vnext/api/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
......@@ -11,7 +11,7 @@ namespace Microsoft.EntityFrameworkCore.Diagnostics;
/// behavior of warnings.
/// </para>
/// </summary>
public static class NpgsqlEventId
public static class NpgsqlEfEventId
{
// Warning: These values must not change between releases.
// Only add new values to the end of sections, never in the middle.
......
......@@ -564,7 +564,7 @@ protected override void Generate(AlterColumnOperation operation, IModel? model,
{
case null:
// Drop the identity, converting the column to a regular int
builder.AppendLine(alterBase).AppendLine("DROP IDENTITY;");
builder.Append(alterBase).AppendLine("DROP IDENTITY;");
break;
case NpgsqlValueGenerationStrategy.IdentityAlwaysColumn:
builder.Append(alterBase).AppendLine("SET GENERATED ALWAYS;");
......
......@@ -158,12 +158,12 @@ public static EventDefinition<string> LogEnumColumnSkipped(IDiagnosticsLogger lo
logger,
static logger => new EventDefinition<string>(
logger.Options,
NpgsqlEventId.EnumColumnSkippedWarning,
NpgsqlEfEventId.EnumColumnSkippedWarning,
LogLevel.Warning,
"NpgsqlEventId.EnumColumnSkippedWarning",
"NpgsqlEfEventId.EnumColumnSkippedWarning",
level => LoggerMessage.Define<string>(
level,
NpgsqlEventId.EnumColumnSkippedWarning,
NpgsqlEfEventId.EnumColumnSkippedWarning,
_resourceManager.GetString("LogEnumColumnSkipped")!)));
}
......@@ -183,12 +183,12 @@ public static EventDefinition<string> LogEnumColumnSkipped(IDiagnosticsLogger lo
logger,
static logger => new EventDefinition<string, string>(
logger.Options,
NpgsqlEventId.ExpressionIndexSkippedWarning,
NpgsqlEfEventId.ExpressionIndexSkippedWarning,
LogLevel.Warning,
"NpgsqlEventId.ExpressionIndexSkippedWarning",
"NpgsqlEfEventId.ExpressionIndexSkippedWarning",
level => LoggerMessage.Define<string, string>(
level,
NpgsqlEventId.ExpressionIndexSkippedWarning,
NpgsqlEfEventId.ExpressionIndexSkippedWarning,
_resourceManager.GetString("LogExpressionIndexSkipped")!)));
}
......@@ -208,12 +208,12 @@ public static EventDefinition<string> LogEnumColumnSkipped(IDiagnosticsLogger lo
logger,
static logger => new EventDefinition<string, string, string, string, string?, bool>(
logger.Options,
NpgsqlEventId.CollationFound,
NpgsqlEfEventId.CollationFound,
LogLevel.Debug,
"NpgsqlEventId.CollationFound",
"NpgsqlEfEventId.CollationFound",
level => LoggerMessage.Define<string, string, string, string, string?, bool>(
level,
NpgsqlEventId.CollationFound,
NpgsqlEfEventId.CollationFound,
_resourceManager.GetString("LogFoundCollation")!)));
}
......@@ -233,9 +233,9 @@ public static FallbackEventDefinition LogFoundColumn(IDiagnosticsLogger logger)
logger,
static logger => new FallbackEventDefinition(
logger.Options,
NpgsqlEventId.ColumnFound,
NpgsqlEfEventId.ColumnFound,
LogLevel.Debug,
"NpgsqlEventId.ColumnFound",
"NpgsqlEfEventId.ColumnFound",
_resourceManager.GetString("LogFoundColumn")!));
}
......@@ -255,12 +255,12 @@ public static FallbackEventDefinition LogFoundColumn(IDiagnosticsLogger logger)
logger,
static logger => new EventDefinition<string, string, string, string>(
logger.Options,
NpgsqlEventId.ForeignKeyFound,
NpgsqlEfEventId.ForeignKeyFound,
LogLevel.Debug,
"NpgsqlEventId.ForeignKeyFound",
"NpgsqlEfEventId.ForeignKeyFound",
level => LoggerMessage.Define<string, string, string, string>(
level,
NpgsqlEventId.ForeignKeyFound,
NpgsqlEfEventId.ForeignKeyFound,
_resourceManager.GetString("LogFoundForeignKey")!)));
}
......@@ -280,12 +280,12 @@ public static FallbackEventDefinition LogFoundColumn(IDiagnosticsLogger logger)
logger,
static logger => new EventDefinition<string, string, bool>(
logger.Options,
NpgsqlEventId.IndexFound,
NpgsqlEfEventId.IndexFound,
LogLevel.Debug,
"NpgsqlEventId.IndexFound",
"NpgsqlEfEventId.IndexFound",
level => LoggerMessage.Define<string, string, bool>(
level,
NpgsqlEventId.IndexFound,
NpgsqlEfEventId.IndexFound,
_resourceManager.GetString("LogFoundIndex")!)));
}
......@@ -305,12 +305,12 @@ public static FallbackEventDefinition LogFoundColumn(IDiagnosticsLogger logger)
logger,
static logger => new EventDefinition<string, string>(
logger.Options,
NpgsqlEventId.PrimaryKeyFound,
NpgsqlEfEventId.PrimaryKeyFound,
LogLevel.Debug,
"NpgsqlEventId.PrimaryKeyFound",
"NpgsqlEfEventId.PrimaryKeyFound",
level => LoggerMessage.Define<string, string>(
level,
NpgsqlEventId.PrimaryKeyFound,
NpgsqlEfEventId.PrimaryKeyFound,
_resourceManager.GetString("LogFoundPrimaryKey")!)));
}
......@@ -330,9 +330,9 @@ public static FallbackEventDefinition LogFoundSequence(IDiagnosticsLogger logger
logger,
static logger => new FallbackEventDefinition(
logger.Options,
NpgsqlEventId.SequenceFound,
NpgsqlEfEventId.SequenceFound,
LogLevel.Debug,
"NpgsqlEventId.SequenceFound",
"NpgsqlEfEventId.SequenceFound",
_resourceManager.GetString("LogFoundSequence")!));
}
......@@ -352,12 +352,12 @@ public static EventDefinition<string> LogFoundTable(IDiagnosticsLogger logger)
logger,
static logger => new EventDefinition<string>(
logger.Options,
NpgsqlEventId.TableFound,
NpgsqlEfEventId.TableFound,
LogLevel.Debug,
"NpgsqlEventId.TableFound",
"NpgsqlEfEventId.TableFound",
level => LoggerMessage.Define<string>(
level,
NpgsqlEventId.TableFound,
NpgsqlEfEventId.TableFound,
_resourceManager.GetString("LogFoundTable")!)));
}
......@@ -377,12 +377,12 @@ public static EventDefinition<string> LogFoundTable(IDiagnosticsLogger logger)
logger,
static logger => new EventDefinition<string?, string>(
logger.Options,
NpgsqlEventId.UniqueConstraintFound,
NpgsqlEfEventId.UniqueConstraintFound,
LogLevel.Debug,
"NpgsqlEventId.UniqueConstraintFound",
"NpgsqlEfEventId.UniqueConstraintFound",
level => LoggerMessage.Define<string?, string>(
level,
NpgsqlEventId.UniqueConstraintFound,
NpgsqlEfEventId.UniqueConstraintFound,
_resourceManager.GetString("LogFoundUniqueConstraint")!)));
}
......@@ -402,12 +402,12 @@ public static EventDefinition<string> LogFoundTable(IDiagnosticsLogger logger)
logger,
static logger => new EventDefinition<string?>(
logger.Options,
NpgsqlEventId.MissingSchemaWarning,
NpgsqlEfEventId.MissingSchemaWarning,
LogLevel.Warning,
"NpgsqlEventId.MissingSchemaWarning",
"NpgsqlEfEventId.MissingSchemaWarning",
level => LoggerMessage.Define<string?>(
level,
NpgsqlEventId.MissingSchemaWarning,
NpgsqlEfEventId.MissingSchemaWarning,
_resourceManager.GetString("LogMissingSchema")!)));
}
......@@ -427,12 +427,12 @@ public static EventDefinition<string> LogFoundTable(IDiagnosticsLogger logger)
logger,
static logger => new EventDefinition<string?>(
logger.Options,
NpgsqlEventId.MissingTableWarning,
NpgsqlEfEventId.MissingTableWarning,
LogLevel.Warning,
"NpgsqlEventId.MissingTableWarning",
"NpgsqlEfEventId.MissingTableWarning",
level => LoggerMessage.Define<string?>(
level,
NpgsqlEventId.MissingTableWarning,
NpgsqlEfEventId.MissingTableWarning,
_resourceManager.GetString("LogMissingTable")!)));
}
......@@ -452,12 +452,12 @@ public static EventDefinition<string> LogFoundTable(IDiagnosticsLogger logger)
logger,
static logger => new EventDefinition<string, string, string, string>(
logger.Options,
NpgsqlEventId.ForeignKeyPrincipalColumnMissingWarning,
NpgsqlEfEventId.ForeignKeyPrincipalColumnMissingWarning,
LogLevel.Warning,
"NpgsqlEventId.ForeignKeyPrincipalColumnMissingWarning",
"NpgsqlEfEventId.ForeignKeyPrincipalColumnMissingWarning",
level => LoggerMessage.Define<string, string, string, string>(
level,
NpgsqlEventId.ForeignKeyPrincipalColumnMissingWarning,
NpgsqlEfEventId.ForeignKeyPrincipalColumnMissingWarning,
_resourceManager.GetString("LogPrincipalColumnNotFound")!)));
}
......@@ -477,12 +477,12 @@ public static EventDefinition<string> LogFoundTable(IDiagnosticsLogger logger)
logger,
static logger => new EventDefinition<string?, string?, string?>(
logger.Options,
NpgsqlEventId.ForeignKeyReferencesMissingPrincipalTableWarning,
NpgsqlEfEventId.ForeignKeyReferencesMissingPrincipalTableWarning,
LogLevel.Warning,
"NpgsqlEventId.ForeignKeyReferencesMissingPrincipalTableWarning",
"NpgsqlEfEventId.ForeignKeyReferencesMissingPrincipalTableWarning",
level => LoggerMessage.Define<string?, string?, string?>(
level,
NpgsqlEventId.ForeignKeyReferencesMissingPrincipalTableWarning,
NpgsqlEfEventId.ForeignKeyReferencesMissingPrincipalTableWarning,
_resourceManager.GetString("LogPrincipalTableNotInSelectionSet")!)));
}
......@@ -502,12 +502,12 @@ public static EventDefinition<string> LogFoundTable(IDiagnosticsLogger logger)
logger,
static logger => new EventDefinition<string?, string>(
logger.Options,
NpgsqlEventId.UnsupportedColumnConstraintSkippedWarning,
NpgsqlEfEventId.UnsupportedColumnConstraintSkippedWarning,
LogLevel.Warning,
"NpgsqlEventId.UnsupportedColumnConstraintSkippedWarning",
"NpgsqlEfEventId.UnsupportedColumnConstraintSkippedWarning",
level => LoggerMessage.Define<string?, string>(
level,
NpgsqlEventId.UnsupportedColumnConstraintSkippedWarning,
NpgsqlEfEventId.UnsupportedColumnConstraintSkippedWarning,
_resourceManager.GetString("LogUnsupportedColumnConstraintSkipped")!)));
}
......@@ -527,12 +527,12 @@ public static EventDefinition<string> LogFoundTable(IDiagnosticsLogger logger)
logger,
static logger => new EventDefinition<string, string>(
logger.Options,
NpgsqlEventId.UnsupportedColumnIndexSkippedWarning,
NpgsqlEfEventId.UnsupportedColumnIndexSkippedWarning,
LogLevel.Warning,
"NpgsqlEventId.UnsupportedColumnIndexSkippedWarning",
"NpgsqlEfEventId.UnsupportedColumnIndexSkippedWarning",
level => LoggerMessage.Define<string, string>(
level,
NpgsqlEventId.UnsupportedColumnIndexSkippedWarning,
NpgsqlEfEventId.UnsupportedColumnIndexSkippedWarning,
_resourceManager.GetString("LogUnsupportedColumnIndexSkipped")!)));
}
......
......@@ -882,6 +882,9 @@ public override void Can_query_with_null_parameters_using_any_nullable_data_type
}
}
[ConditionalFact(Skip = "DateTimeOffset with non-zero offset, https://github.com/dotnet/efcore/issues/26068")]
public override void Can_insert_and_read_back_all_nullable_data_types_with_values_set_to_non_null() {}
[ConditionalFact(Skip = "DateTimeOffset with non-zero offset, https://github.com/dotnet/efcore/issues/26068")]
public override void Can_insert_and_read_back_non_nullable_backed_data_types() {}
......@@ -951,6 +954,8 @@ public class BuiltInDataTypesNpgsqlFixture : BuiltInDataTypesFixtureBase
public override bool SupportsDecimalComparisons => true;
public override bool PreservesDateTimeKind => false;
protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance;
protected override bool ShouldLogCategory(string logCategory)
......
......@@ -77,6 +77,8 @@ public class ConvertToProviderTypesNpgsqlFixture : ConvertToProviderTypesFixture
public override DateTime DefaultDateTime => new();
public override bool PreservesDateTimeKind => false;
protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
{
base.OnModelCreating(modelBuilder, context);
......@@ -104,4 +106,4 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
= new DateTimeOffset(new DateTime(), TimeSpan.Zero);
}
}
}
\ No newline at end of file
}
......@@ -49,6 +49,8 @@ public class CustomConvertersNpgsqlFixture : CustomConvertersFixtureBase
public override DateTime DefaultDateTime => new();
public override bool PreservesDateTimeKind => false;
protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
{
base.OnModelCreating(modelBuilder, context);
......@@ -76,4 +78,4 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
= new DateTimeOffset(new DateTime(), TimeSpan.Zero);
}
}
}
\ No newline at end of file
}
......@@ -3,6 +3,7 @@
<PropertyGroup>
<AssemblyName>Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests</AssemblyName>
<RootNamespace>Npgsql.EntityFrameworkCore.PostgreSQL</RootNamespace>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>
<ItemGroup>
......
......@@ -25,7 +25,7 @@ public override async Task Create_table()
AssertSql(
@"CREATE TABLE ""People"" (
""Id"" integer NOT NULL,
""Id"" integer GENERATED BY DEFAULT AS IDENTITY,
""Name"" text NULL,
CONSTRAINT ""PK_People"" PRIMARY KEY (""Id"")
);");
......@@ -45,16 +45,18 @@ public override async Task Create_table_all_settings()
END $EF$;",
//
@"CREATE TABLE dbo2.""People"" (
""CustomId"" integer NOT NULL,
""CustomId"" integer GENERATED BY DEFAULT AS IDENTITY,
""EmployerId"" integer NOT NULL,
""SSN"" character varying(11) COLLATE ""POSIX"" NOT NULL,
CONSTRAINT ""PK_People"" PRIMARY KEY (""CustomId""),
CONSTRAINT ""AK_People_SSN"" UNIQUE (""SSN""),
CONSTRAINT ""CK_People_EmployerId"" CHECK (""EmployerId"" > 0),
CONSTRAINT ""FK_People_Employers_EmployerId"" FOREIGN KEY (""EmployerId"") REFERENCES ""Employers"" (""Id"")
CONSTRAINT ""FK_People_Employers_EmployerId"" FOREIGN KEY (""EmployerId"") REFERENCES ""Employers"" (""Id"") ON DELETE CASCADE
);
COMMENT ON TABLE dbo2.""People"" IS 'Table comment';
COMMENT ON COLUMN dbo2.""People"".""EmployerId"" IS 'Employer ID comment';");
COMMENT ON COLUMN dbo2.""People"".""EmployerId"" IS 'Employer ID comment';",
//
@"CREATE INDEX ""IX_People_EmployerId"" ON dbo2.""People"" (""EmployerId"");");
}
public override async Task Create_table_no_key()
......@@ -73,8 +75,9 @@ public override async Task Create_table_with_comments()
AssertSql(
@"CREATE TABLE ""People"" (
""Id"" integer NOT NULL,
""Name"" text NULL
""Id"" integer GENERATED BY DEFAULT AS IDENTITY,
""Name"" text NULL,
CONSTRAINT ""PK_People"" PRIMARY KEY (""Id"")
);
COMMENT ON TABLE ""People"" IS 'Table comment';
COMMENT ON COLUMN ""People"".""Name"" IS 'Column comment';");
......@@ -86,8 +89,9 @@ public override async Task Create_table_with_multiline_comments()
AssertSql(
@"CREATE TABLE ""People"" (
""Id"" integer NOT NULL,
""Name"" text NULL
""Id"" integer GENERATED BY DEFAULT AS IDENTITY,
""Name"" text NULL,
CONSTRAINT ""PK_People"" PRIMARY KEY (""Id"")
);
COMMENT ON TABLE ""People"" IS 'This is a multi-line
table comment.
......@@ -118,10 +122,11 @@ public override async Task Create_table_with_computed_column(bool? stored)
AssertSql(
@"CREATE TABLE ""People"" (
""Id"" integer NOT NULL,
""Id"" integer GENERATED BY DEFAULT AS IDENTITY,
""Sum"" text GENERATED ALWAYS AS (""X"" + ""Y"") STORED,
""X"" integer NOT NULL,
""Y"" integer NOT NULL
""Y"" integer NOT NULL,
CONSTRAINT ""PK_People"" PRIMARY KEY (""Id"")
);");
}
......@@ -142,7 +147,8 @@ public virtual async Task Create_table_with_identity_by_default()
AssertSql(
@"CREATE TABLE ""People"" (
""Id"" integer GENERATED BY DEFAULT AS IDENTITY
""Id"" integer GENERATED BY DEFAULT AS IDENTITY,
CONSTRAINT ""PK_People"" PRIMARY KEY (""Id"")
);");
}
......@@ -163,7 +169,8 @@ public virtual async Task Create_table_with_identity_always()
AssertSql(
@"CREATE TABLE ""People"" (
""Id"" integer GENERATED ALWAYS AS IDENTITY
""Id"" integer GENERATED ALWAYS AS IDENTITY,
CONSTRAINT ""PK_People"" PRIMARY KEY (""Id"")
);");
}
......@@ -191,7 +198,8 @@ public virtual async Task Create_table_with_identity_always_with_options()
AssertSql(
@"CREATE TABLE ""People"" (
""Id"" integer GENERATED ALWAYS AS IDENTITY (START WITH 10 INCREMENT BY 2 MAXVALUE 2000)
""Id"" integer GENERATED ALWAYS AS IDENTITY (START WITH 10 INCREMENT BY 2 MAXVALUE 2000),
CONSTRAINT ""PK_People"" PRIMARY KEY (""Id"")
);");
}
......@@ -213,7 +221,8 @@ public virtual async Task Create_table_with_serial()
AssertSql(
@"CREATE TABLE ""People"" (
""Id"" serial NOT NULL
""Id"" serial NOT NULL,
CONSTRAINT ""PK_People"" PRIMARY KEY (""Id"")
);");
}
......@@ -239,7 +248,7 @@ public virtual async Task Create_table_with_system_column()
AssertSql(
@"CREATE TABLE ""People"" (
""Id"" integer NOT NULL,
""Id"" integer GENERATED BY DEFAULT AS IDENTITY,
CONSTRAINT ""PK_People"" PRIMARY KEY (""Id"")
);");
}
......@@ -261,7 +270,7 @@ public virtual async Task Create_table_with_storage_parameter()
AssertSql(
@"CREATE TABLE ""People"" (
""Id"" integer NOT NULL,
""Id"" integer GENERATED BY DEFAULT AS IDENTITY,
CONSTRAINT ""PK_People"" PRIMARY KEY (""Id"")
)
WITH (fillfactor=70, user_catalog_table=true);");
......@@ -283,7 +292,7 @@ public virtual async Task Create_table_with_unlogged()
AssertSql(
@"CREATE UNLOGGED TABLE ""People"" (
""Id"" integer NOT NULL,
""Id"" integer GENERATED BY DEFAULT AS IDENTITY,
CONSTRAINT ""PK_People"" PRIMARY KEY (""Id"")
);");
}
......@@ -404,7 +413,11 @@ public override async Task Rename_table()
await base.Rename_table();
AssertSql(
@"ALTER TABLE ""People"" RENAME TO ""Persons"";");
@"ALTER TABLE ""People"" DROP CONSTRAINT ""PK_People"";",
//
@"ALTER TABLE ""People"" RENAME TO ""Persons"";",
//
@"ALTER TABLE ""Persons"" ADD CONSTRAINT ""PK_Persons"" PRIMARY KEY (""Id"");");
}
public override async Task Rename_table_with_primary_key()
......@@ -451,7 +464,8 @@ public override async Task Create_schema()
END $EF$;",
//
@"CREATE TABLE ""SomeOtherSchema"".""People"" (
""Id"" integer NOT NULL
""Id"" integer GENERATED BY DEFAULT AS IDENTITY,
CONSTRAINT ""PK_People"" PRIMARY KEY (""Id"")
);");
}
......@@ -467,7 +481,8 @@ public virtual async Task Create_schema_public_is_ignored()
AssertSql(
@"CREATE TABLE public.""People"" (
""Id"" integer NOT NULL
""Id"" integer GENERATED BY DEFAULT AS IDENTITY,
CONSTRAINT ""PK_People"" PRIMARY KEY (""Id"")
);");
}
......@@ -1042,7 +1057,7 @@ public override async Task Alter_column_change_computed()
}
[ConditionalFact]
public virtual async Task Alter_column_change_computed_recreates_indexes()
public override async Task Alter_column_change_computed_recreates_indexes()
{
if (TestEnvironment.PostgresVersion.IsUnder(12))
{
......@@ -1184,13 +1199,8 @@ public override async Task Alter_column_remove_comment()
public virtual async Task Alter_column_make_identity_by_default()
{
await Test(
builder => builder.Entity(
"People", e =>
{
e.Property<int>("Id");
e.HasKey("Id");
}),
_ => { },
builder => builder.Entity("People").Property<int>("Id")
.ValueGeneratedNever(),
builder => builder.Entity("People").Property<int>("Id")
.UseIdentityByDefaultColumn(),
model =>
......@@ -1228,8 +1238,7 @@ public virtual async Task Alter_column_make_identity_always()
});
AssertSql(
@"ALTER TABLE ""People"" ALTER COLUMN ""Id"" DROP DEFAULT;
ALTER TABLE ""People"" ALTER COLUMN ""Id"" ADD GENERATED ALWAYS AS IDENTITY;");
@"ALTER TABLE ""People"" ALTER COLUMN ""Id"" SET GENERATED ALWAYS;");
}
[Fact]
......@@ -1262,13 +1271,8 @@ public virtual async Task Alter_column_make_default_into_identity()
public virtual async Task Alter_column_make_identity_by_default_with_options()
{
await Test(
builder => builder.Entity(
"People", e =>
{
e.Property<int>("Id");
e.HasKey("Id");
}),
_ => { },
builder => builder.Entity("People").Property<int>("Id")
.ValueGeneratedNever(),
builder => builder.Entity("People").Property<int>("Id")
.UseIdentityByDefaultColumn()
.HasIdentityOptions(startValue: 10, incrementBy: 2, maxValue: 2000),
......@@ -1320,8 +1324,8 @@ public virtual async Task Alter_column_make_identity_with_default_options()
});
AssertSql(
@"ALTER TABLE ""People"" ALTER COLUMN ""Id"" DROP DEFAULT;
ALTER TABLE ""People"" ALTER COLUMN ""Id"" ADD GENERATED BY DEFAULT AS IDENTITY;");
@"ALTER TABLE ""People"" ALTER COLUMN ""Id"" RESTART WITH 1;
ALTER TABLE ""People"" ALTER COLUMN ""Id"" SET MINVALUE 1;");
}
[Fact]
......@@ -1390,13 +1394,8 @@ public virtual async Task Alter_column_remove_identity_options()
public virtual async Task Alter_column_make_serial()
{
await Test(
builder => builder.Entity(
"People", e =>
{
e.Property<int>("Id");
e.HasKey("Id");
}),
_ => { },
builder => builder.Entity("People").Property<int>("Id")
.ValueGeneratedNever(),
builder => builder.Entity("People").Property<int>("Id")
.UseSerialColumn(),
model =>
......@@ -1420,14 +1419,9 @@ public virtual async Task Alter_column_make_serial()
public virtual async Task Alter_column_make_serial_in_non_default_schema()
{
await Test(
builder => builder.Entity(
"People", e =>
{
e.ToTable("People", "some_schema");
e.Property<int>("Id");
e.HasKey("Id");
}),
_ => { },
builder => builder.Entity("People", e => e.ToTable("People", "some_schema")),
builder => builder.Entity("People").Property<int>("Id")
.ValueGeneratedNever(),
builder => builder.Entity("People").Property<int>("Id")
.UseSerialColumn(),
model =>
......@@ -1451,13 +1445,8 @@ public virtual async Task Alter_column_make_serial_in_non_default_schema()
public virtual async Task Alter_column_long_make_bigserial()
{
await Test(
builder => builder.Entity(
"People", e =>
{
e.Property<long>("Id");
e.HasKey("Id");
}),
_ => { },
builder => builder.Entity("People").Property<long>("Id")
.ValueGeneratedNever(),
builder => builder.Entity("People").Property<long>("Id")
.UseSerialColumn(),
model =>
......@@ -2206,9 +2195,20 @@ public override async Task Rename_index()
#region Key and constraint
public override async Task Add_primary_key()
public override async Task Add_primary_key_int()
{
await base.Add_primary_key_int();
AssertSql(
@"ALTER TABLE ""People"" ALTER COLUMN ""SomeField"" DROP DEFAULT;
ALTER TABLE ""People"" ALTER COLUMN ""SomeField"" ADD GENERATED BY DEFAULT AS IDENTITY;",
//
@"ALTER TABLE ""People"" ADD CONSTRAINT ""PK_People"" PRIMARY KEY (""SomeField"");");
}
public override async Task Add_primary_key_string()
{
await base.Add_primary_key();
await base.Add_primary_key_string();
AssertSql(
@"ALTER TABLE ""People"" ADD CONSTRAINT ""PK_People"" PRIMARY KEY (""SomeField"");");
......@@ -2219,6 +2219,9 @@ public override async Task Add_primary_key_with_name()
await base.Add_primary_key_with_name();
AssertSql(
@"ALTER TABLE ""People"" ALTER COLUMN ""SomeField"" SET NOT NULL;
ALTER TABLE ""People"" ALTER COLUMN ""SomeField"" SET DEFAULT '';",
//
@"ALTER TABLE ""People"" ADD CONSTRAINT ""PK_Foo"" PRIMARY KEY (""SomeField"");");
}
......@@ -2230,9 +2233,19 @@ public override async Task Add_primary_key_composite_with_name()
@"ALTER TABLE ""People"" ADD CONSTRAINT ""PK_Foo"" PRIMARY KEY (""SomeField1"", ""SomeField2"");");
}
public override async Task Drop_primary_key()
public override async Task Drop_primary_key_int()
{
await base.Drop_primary_key_int();
AssertSql(
@"ALTER TABLE ""People"" DROP CONSTRAINT ""PK_People"";",
//
@"ALTER TABLE ""People"" ALTER COLUMN ""SomeField"" DROP IDENTITY;");
}
public override async Task Drop_primary_key_string()
{
await base.Drop_primary_key();
await base.Drop_primary_key_string();
AssertSql(
@"ALTER TABLE ""People"" DROP CONSTRAINT ""PK_People"";");
......@@ -2246,7 +2259,9 @@ public override async Task Add_foreign_key_with_name()
await base.Add_foreign_key_with_name();
AssertSql(
@"ALTER TABLE ""Orders"" ADD CONSTRAINT ""FK_Foo"" FOREIGN KEY (""CustomerId"") REFERENCES ""Customers"" (""Id"");");
@"CREATE INDEX ""IX_Orders_CustomerId"" ON ""Orders"" (""CustomerId"");",
//
@"ALTER TABLE ""Orders"" ADD CONSTRAINT ""FK_Foo"" FOREIGN KEY (""CustomerId"") REFERENCES ""Customers"" (""Id"") ON DELETE CASCADE;");
}
public override async Task Drop_foreign_key()
......@@ -2254,7 +2269,9 @@ public override async Task Drop_foreign_key()
await base.Drop_foreign_key();
AssertSql(
@"ALTER TABLE ""Orders"" DROP CONSTRAINT ""FK_Orders_Customers_CustomerId"";");
@"ALTER TABLE ""Orders"" DROP CONSTRAINT ""FK_Orders_Customers_CustomerId"";",
//
@"DROP INDEX ""IX_Orders_CustomerId"";");
}
public override async Task Add_unique_constraint()
......@@ -2426,7 +2443,14 @@ public override async Task InsertDataOperation()
INSERT INTO ""Person"" (""Id"", ""Name"")
VALUES (4, 'Harry Strickland');
INSERT INTO ""Person"" (""Id"", ""Name"")
VALUES (5, NULL);");
VALUES (5, NULL);",
//
@"SELECT setval(
pg_get_serial_sequence('""Person""', 'Id'),
GREATEST(
(SELECT MAX(""Id"") FROM ""Person"") + 1,
nextval(pg_get_serial_sequence('""Person""', 'Id'))),
false);");
}
public override async Task DeleteDataOperation_simple_key()
......@@ -2781,7 +2805,7 @@ public virtual Task Alter_collation_throws()
public class MigrationsNpgsqlFixture : MigrationsFixtureBase
{
protected override string StoreName { get; } = nameof(MigrationsNpgsqlTest);
protected override string StoreName => nameof(MigrationsNpgsqlTest);
protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance;
public override TestHelpers TestHelpers => NpgsqlTestHelpers.Instance;
......@@ -2794,7 +2818,7 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build
new NpgsqlDbContextOptionsBuilder(base.AddOptions(builder)
// Some tests create expression indexes, but these cannot be reverse-engineered.
.ConfigureWarnings(
w => { w.Ignore(NpgsqlEventId.ExpressionIndexSkippedWarning); }))
w => { w.Ignore(NpgsqlEfEventId.ExpressionIndexSkippedWarning); }))
// Various migration operations PG-version sensitive, configure the context with the actual version
// we're connecting to.
.SetPostgresVersion(TestEnvironment.PostgresVersion);
......@@ -2802,4 +2826,9 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build
return builder;
}
}
protected override ICollection<BuildReference> GetAdditionalReferences()
=> AdditionalReferences;
private static readonly BuildReference[] AdditionalReferences = { BuildReference.ByName("Npgsql") };
}
......@@ -258,7 +258,7 @@ public async Task Throws_when_database_does_not_exist(bool async)
{
using var testDatabase = NpgsqlTestStore.GetOrCreate("NonExisting");
var databaseCreator = GetDatabaseCreator(testDatabase);
await databaseCreator.ExecutionStrategyFactory.Create().ExecuteAsync(
await databaseCreator.ExecutionStrategy.ExecuteAsync(
databaseCreator,
async creator =>
{
......@@ -652,9 +652,7 @@ public bool HasTablesBase()
public Task<bool> HasTablesAsyncBase(CancellationToken cancellationToken = default)
=> HasTablesAsync(cancellationToken);
public IExecutionStrategyFactory ExecutionStrategyFactory
#pragma warning disable CS0618 // Type or member is obsolete
=> Dependencies.ExecutionStrategyFactory;
#pragma warning restore CS0618 // Type or member is obsolete
public IExecutionStrategy ExecutionStrategy
=> Dependencies.ExecutionStrategy;
}
}
\ No newline at end of file
}
......@@ -42,10 +42,11 @@ public void StartsWith_param_pattern()
Assert.Equal(1, result.Id);
AssertSql(
@"@__param_0='some'
@__param_0_1='some'
SELECT s.""Id"", s.""CaseInsensitiveText""
FROM ""SomeEntities"" AS s
WHERE (@__param_0 = '') OR ((s.""CaseInsensitiveText"" IS NOT NULL) AND ((s.""CaseInsensitiveText"" LIKE @__param_0 || '%' ESCAPE '') AND (left(s.""CaseInsensitiveText"", length(@__param_0))::citext = @__param_0::citext)))
WHERE @__param_0 = '' OR ((s.""CaseInsensitiveText"" IS NOT NULL) AND (s.""CaseInsensitiveText"" LIKE @__param_0_1 || '%' ESCAPE '') AND left(s.""CaseInsensitiveText"", length(@__param_0))::citext = @__param_0::citext)
LIMIT 2");
}
......@@ -62,7 +63,7 @@ public void StartsWith_param_instance()
SELECT s.""Id"", s.""CaseInsensitiveText""
FROM ""SomeEntities"" AS s
WHERE (s.""CaseInsensitiveText"" = '') OR ((s.""CaseInsensitiveText"" IS NOT NULL) AND ((@__param_0 LIKE s.""CaseInsensitiveText"" || '%' ESCAPE '') AND (left(@__param_0, length(s.""CaseInsensitiveText""))::citext = s.""CaseInsensitiveText""::citext)))
WHERE s.""CaseInsensitiveText"" = '' OR ((s.""CaseInsensitiveText"" IS NOT NULL) AND (@__param_0 LIKE s.""CaseInsensitiveText"" || '%' ESCAPE '') AND left(@__param_0, length(s.""CaseInsensitiveText""))::citext = s.""CaseInsensitiveText""::citext)
LIMIT 2");
}
......@@ -90,10 +91,11 @@ public void EndsWith_param_pattern()
Assert.Equal(1, result.Id);
AssertSql(
@"@__param_0='sometext'
@__param_0_1='sometext'
SELECT s.""Id"", s.""CaseInsensitiveText""
FROM ""SomeEntities"" AS s
WHERE (@__param_0 = '') OR ((s.""CaseInsensitiveText"" IS NOT NULL) AND (right(s.""CaseInsensitiveText"", length(@__param_0))::citext = @__param_0::citext))
WHERE @__param_0 = '' OR ((s.""CaseInsensitiveText"" IS NOT NULL) AND right(s.""CaseInsensitiveText"", length(@__param_0_1))::citext = @__param_0::citext)
LIMIT 2");
}
......@@ -110,7 +112,7 @@ public void EndsWith_param_instance()
SELECT s.""Id"", s.""CaseInsensitiveText""
FROM ""SomeEntities"" AS s
WHERE (s.""CaseInsensitiveText"" = '') OR ((s.""CaseInsensitiveText"" IS NOT NULL) AND (right(@__param_0, length(s.""CaseInsensitiveText""))::citext = s.""CaseInsensitiveText""::citext))
WHERE s.""CaseInsensitiveText"" = '' OR ((s.""CaseInsensitiveText"" IS NOT NULL) AND right(@__param_0, length(s.""CaseInsensitiveText""))::citext = s.""CaseInsensitiveText""::citext)
LIMIT 2");
}
......@@ -141,7 +143,7 @@ public void Contains_param_pattern()
SELECT s.""Id"", s.""CaseInsensitiveText""
FROM ""SomeEntities"" AS s
WHERE (@__param_0 = '') OR (strpos(s.""CaseInsensitiveText"", @__param_0) > 0)
WHERE @__param_0 = '' OR strpos(s.""CaseInsensitiveText"", @__param_0) > 0
LIMIT 2");
}
......@@ -158,7 +160,7 @@ public void Contains_param_instance()
SELECT s.""Id"", s.""CaseInsensitiveText""
FROM ""SomeEntities"" AS s
WHERE (s.""CaseInsensitiveText"" = '') OR (strpos(@__param_0, s.""CaseInsensitiveText"") > 0)
WHERE s.""CaseInsensitiveText"" = '' OR strpos(@__param_0, s.""CaseInsensitiveText"") > 0
LIMIT 2");
}
......
......@@ -10,4 +10,9 @@ public class ComplexNavigationsCollectionsQueryNpgsqlTest : ComplexNavigationsCo
Fixture.TestSqlLoggerFactory.Clear();
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}
}
\ No newline at end of file
public override async Task Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(bool async)
// Nested collection with ToList. Issue #23303.
=> await Assert.ThrowsAsync<ArgumentNullException>(
() => base.Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(async));
}
......@@ -11,4 +11,9 @@ public class ComplexNavigationsCollectionsSharedTypeQueryNpgsqlTest : ComplexNav
Fixture.TestSqlLoggerFactory.Clear();
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}
}
\ No newline at end of file
public override async Task Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(bool async)
// Nested collection with ToList. Issue #23303.
=> await Assert.ThrowsAsync<ArgumentNullException>(
() => base.Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(async));
}
......@@ -10,4 +10,9 @@ public class ComplexNavigationsCollectionsSplitQueryNpgsqlTest : ComplexNavigati
Fixture.TestSqlLoggerFactory.Clear();
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}
}
\ No newline at end of file
public override async Task Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(bool async)
// Nested collection with ToList. Issue #23303.
=> await Assert.ThrowsAsync<ArgumentNullException>(
() => base.Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(async));
}
......@@ -11,4 +11,9 @@ public class ComplexNavigationsCollectionsSplitSharedTypeQueryNpgsqlTest : Compl
Fixture.TestSqlLoggerFactory.Clear();
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}
}
\ No newline at end of file
public override async Task Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(bool async)
// Nested collection with ToList. Issue #23303.
=> await Assert.ThrowsAsync<ArgumentNullException>(
() => base.Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(async));
}
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query;
using Xunit.Sdk;
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query;
public class ComplexNavigationsQueryNpgsqlTest : ComplexNavigationsQueryRelationalTestBase<ComplexNavigationsQueryNpgsqlFixture>
{
......@@ -11,4 +13,19 @@ public ComplexNavigationsQueryNpgsqlTest(ComplexNavigationsQueryNpgsqlFixture fi
[ConditionalTheory(Skip = "https://github.com/dotnet/efcore/issues/26353")]
public override Task Subquery_with_Distinct_Skip_FirstOrDefault_without_OrderBy(bool async)
=> base.Subquery_with_Distinct_Skip_FirstOrDefault_without_OrderBy(async);
}
\ No newline at end of file
public override async Task Join_with_result_selector_returning_queryable_throws_validation_error(bool async)
=> await Assert.ThrowsAsync<ArgumentException>(
() => base.Join_with_result_selector_returning_queryable_throws_validation_error(async));
public override Task GroupJoin_client_method_in_OrderBy(bool async)
=> AssertTranslationFailedWithDetails(
() => base.GroupJoin_client_method_in_OrderBy(async),
CoreStrings.QueryUnableToTranslateMethod(
"Microsoft.EntityFrameworkCore.Query.ComplexNavigationsQueryTestBase<Npgsql.EntityFrameworkCore.PostgreSQL.Query.ComplexNavigationsQueryNpgsqlFixture>",
"ClientMethodNullableInt"));
public override Task Nested_SelectMany_correlated_with_join_table_correctly_translated_to_apply(bool async)
=> Assert.ThrowsAsync<EqualException>(
async () => await base.Nested_SelectMany_correlated_with_join_table_correctly_translated_to_apply(async));
}
using Xunit.Sdk;
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query;
public class ComplexNavigationsSharedTypeQueryNpgsqlTest
......@@ -24,4 +26,19 @@ public override Task Distinct_skip_without_orderby(bool async)
[ConditionalTheory(Skip = "https://github.com/dotnet/efcore/pull/22532")]
public override Task Distinct_take_without_orderby(bool async)
=> base.Distinct_take_without_orderby(async);
public override async Task Join_with_result_selector_returning_queryable_throws_validation_error(bool async)
=> await Assert.ThrowsAsync<ArgumentException>(
() => base.Join_with_result_selector_returning_queryable_throws_validation_error(async));
public override Task GroupJoin_client_method_in_OrderBy(bool async)
=> AssertTranslationFailedWithDetails(
() => base.GroupJoin_client_method_in_OrderBy(async),
CoreStrings.QueryUnableToTranslateMethod(
"Microsoft.EntityFrameworkCore.Query.ComplexNavigationsQueryTestBase<Npgsql.EntityFrameworkCore.PostgreSQL.Query.ComplexNavigationsSharedTypeQueryNpgsqlFixture>",
"ClientMethodNullableInt"));
public override Task Nested_SelectMany_correlated_with_join_table_correctly_translated_to_apply(bool async)
=> Assert.ThrowsAsync<EqualException>(
async () => await base.Nested_SelectMany_correlated_with_join_table_correctly_translated_to_apply(async));
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities;
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query;
public class Ef6GroupByNpgsqlTest : Ef6GroupByTestBase<Ef6GroupByNpgsqlTest.Ef6GroupByNpgsqlFixture>
{
public Ef6GroupByNpgsqlTest(Ef6GroupByNpgsqlFixture fixture, ITestOutputHelper testOutputHelper)
: base(fixture)
{
Fixture.TestSqlLoggerFactory.Clear();
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}
[ConditionalTheory(Skip = "https://github.com/dotnet/efcore/issues/27155")]
public override Task Average_Grouped_from_LINQ_101(bool async)
=> base.Average_Grouped_from_LINQ_101(async);
[ConditionalTheory(Skip = "https://github.com/dotnet/efcore/issues/27155")]
public override Task Whats_new_2021_sample_10(bool async)
=> base.Whats_new_2021_sample_10(async);
public class Ef6GroupByNpgsqlFixture : Ef6GroupByFixtureBase
{
public TestSqlLoggerFactory TestSqlLoggerFactory
=> (TestSqlLoggerFactory)ListLoggerFactory;
protected override ITestStoreFactory TestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
{
base.OnModelCreating(modelBuilder, context);
modelBuilder.Entity<OrderForLinq>().Property(o => o.OrderDate).HasColumnType("timestamp");
}
}
}
......@@ -162,7 +162,7 @@ public override async Task DateTimeOffset_Contains_Less_than_Greater_than(bool a
SELECT m.""Id"", m.""CodeName"", m.""Date"", m.""Duration"", m.""Rating"", m.""Time"", m.""Timeline""
FROM ""Missions"" AS m
WHERE ((@__start_0 <= date_trunc('day', m.""Timeline"")::timestamptz) AND (m.""Timeline"" < @__end_1)) AND m.""Timeline"" = ANY (@__dates_2)");
WHERE @__start_0 <= date_trunc('day', m.""Timeline"")::timestamptz AND m.""Timeline"" < @__end_1 AND m.""Timeline"" = ANY (@__dates_2)");
}
// Base implementation uses DateTimeOffset.Now, which we don't translate by design. Use DateTimeOffset.UtcNow instead.
......
......@@ -354,7 +354,7 @@ public void Subpath2()
AssertSql(
@"SELECT l.""Id"", l.""Path"", l.""PathAsString""
FROM ""LTreeEntities"" AS l
WHERE (nlevel(l.""Path"") > 2) AND (subpath(l.""Path"", 2) = 'Astronomy.Astrophysics')
WHERE nlevel(l.""Path"") > 2 AND subpath(l.""Path"", 2) = 'Astronomy.Astrophysics'
LIMIT 2");
}
......
using Microsoft.EntityFrameworkCore.TestModels.Northwind;
using Npgsql.EntityFrameworkCore.PostgreSQL.Internal;
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query;
public class NorthwindAggregateOperatorsQueryNpgsqlTest : NorthwindAggregateOperatorsQueryRelationalTestBase<NorthwindQueryNpgsqlFixture<NoopModelCustomizer>>
......@@ -10,6 +13,16 @@ public NorthwindAggregateOperatorsQueryNpgsqlTest(NorthwindQueryNpgsqlFixture<No
// Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}
// Overriding to add equality tolerance because of floating point precision
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public override Task Average_over_max_subquery_is_client_eval(bool async)
=> AssertAverage(
async,
ss => ss.Set<Customer>().OrderBy(c => c.CustomerID).Take(3),
selector: c => (decimal)c.Orders.Average(o => 5 + o.OrderDetails.Max(od => od.ProductID)),
asserter: (a, b) => Assert.Equal(a, b, 15));
public override async Task Contains_with_local_uint_array_closure(bool async)
{
await base.Contains_with_local_uint_array_closure(async);
......@@ -49,9 +62,16 @@ public override async Task Contains_with_local_nullable_uint_array_closure(bool
WHERE e.""EmployeeID"" = ANY (@__ids_0)");
}
public override async Task Contains_with_local_anonymous_type_array_closure(bool async)
// Aggregates. Issue #15937.
=> await AssertTranslationFailed(() => base.Contains_with_local_anonymous_type_array_closure(async));
public override async Task Contains_with_local_tuple_array_closure(bool async)
=> await AssertTranslationFailed(() => base.Contains_with_local_tuple_array_closure(async));
private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
protected override void ClearLog()
=> Fixture.TestSqlLoggerFactory.Clear();
}
\ No newline at end of file
}
......@@ -21,7 +21,7 @@ public override async Task IsNullOrWhiteSpace_in_predicate(bool async)
AssertSql(
@"SELECT c.""CustomerID"", c.""Address"", c.""City"", c.""CompanyName"", c.""ContactName"", c.""ContactTitle"", c.""Country"", c.""Fax"", c.""Phone"", c.""PostalCode"", c.""Region""
FROM ""Customers"" AS c
WHERE (c.""Region"" IS NULL) OR (btrim(c.""Region"", E' \t\n\r') = '')");
WHERE (c.""Region"" IS NULL) OR btrim(c.""Region"", E' \t\n\r') = ''");
}
public override Task Where_math_log_new_base(bool async)
......@@ -294,4 +294,4 @@ protected override void ClearLog()
private void AssertContainsSqlFragment(string expectedFragment)
=> Assert.Contains(Fixture.TestSqlLoggerFactory.SqlStatements, s => s.Contains(expectedFragment));
}
\ No newline at end of file
}
......@@ -19,6 +19,10 @@ public override async Task Select_datetime_DayOfWeek_component(bool async)
FROM ""Orders"" AS o");
}
[ConditionalTheory(Skip = "https://github.com/dotnet/efcore/issues/27152")]
public override Task Reverse_in_subquery_via_pushdown(bool async)
=> base.Reverse_in_subquery_via_pushdown(async);
public override Task Member_binding_after_ctor_arguments_fails_with_client_eval(bool async)
=> AssertTranslationFailed(() => base.Member_binding_after_ctor_arguments_fails_with_client_eval(async));
......@@ -27,4 +31,4 @@ private void AssertSql(params string[] expected)
protected override void ClearLog()
=> Fixture.TestSqlLoggerFactory.Clear();
}
\ No newline at end of file
}
......@@ -39,7 +39,7 @@ public async Task Row_value_comparison_not_rewritten_with_incompatible_operators
AssertSql(
@"SELECT e.""Id"", e.""X"", e.""Y"", e.""Z""
FROM ""Entities"" AS e
WHERE (e.""X"" > 5) OR ((e.""X"" = 5) AND (e.""Y"" < 6))");
WHERE e.""X"" > 5 OR (e.""X"" = 5 AND e.""Y"" < 6)");
}
[ConditionalTheory]
......@@ -54,7 +54,7 @@ public async Task Row_value_comparison_not_rewritten_with_incompatible_operands(
AssertSql(
@"SELECT e.""Id"", e.""X"", e.""Y"", e.""Z""
FROM ""Entities"" AS e
WHERE (e.""Z"" > 5) OR ((e.""X"" = 5) AND (e.""Y"" > 6))");
WHERE e.""Z"" > 5 OR (e.""X"" = 5 AND e.""Y"" > 6)");
}
[ConditionalTheory]
......
......@@ -50,7 +50,7 @@ public override async Task DateTimeOffset_Contains_Less_than_Greater_than(bool a
SELECT m.""Id"", m.""CodeName"", m.""Date"", m.""Duration"", m.""Rating"", m.""Time"", m.""Timeline""
FROM ""Missions"" AS m
WHERE ((@__start_0 <= date_trunc('day', m.""Timeline"")::timestamptz) AND (m.""Timeline"" < @__end_1)) AND m.""Timeline"" = ANY (@__dates_2)");
WHERE @__start_0 <= date_trunc('day', m.""Timeline"")::timestamptz AND m.""Timeline"" < @__end_1 AND m.""Timeline"" = ANY (@__dates_2)");
}
public override async Task DateTimeOffset_Date_returns_datetime(bool async)
......
......@@ -38,7 +38,9 @@ public IRelationalCommandBuilder AddParameter(IRelationalParameter parameter)
return this;
}
public IRelationalTypeMappingSource TypeMappingSource => Dependencies.TypeMappingSource;
[Obsolete("Code trying to add parameter should add type mapped parameter using TypeMappingSource directly.")]
public IRelationalTypeMappingSource TypeMappingSource
=> Dependencies.TypeMappingSource;
public IRelationalCommand Build()
=> new TestRelationalCommand(
......@@ -216,4 +218,4 @@ private string PreExecution(IRelationalConnection connection)
public void PopulateFrom(IRelationalCommandTemplate command)
=> _realRelationalCommand.PopulateFrom(command);
}
}
\ No newline at end of file
}
......@@ -75,7 +75,8 @@ public static RelationalConnectionDependencies CreateDependencies(DbContextOptio
TestServiceFactory.Instance.Create<TypeMappingSourceDependencies>(),
TestServiceFactory.Instance.Create<RelationalTypeMappingSourceDependencies>(),
new NpgsqlSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies()),
new NpgsqlOptions()))));
new NpgsqlOptions()),
new ExceptionDetector())));
}
private const string ConnectionString = "Fake Connection String";
......@@ -96,4 +97,4 @@ public static RelationalConnectionDependencies CreateDependencies(DbContextOptio
private class FakeDbContext : DbContext
{
}
}
\ No newline at end of file
}
......@@ -195,6 +195,32 @@ public class FakeRelationalCommandDiagnosticsLogger
CancellationToken cancellationToken = default)
=> Task.CompletedTask;
public void CommandCanceled(
IRelationalConnection connection,
DbCommand command,
DbContext? context,
DbCommandMethod executeMethod,
Guid commandId,
Guid connectionId,
DateTimeOffset startTime,
TimeSpan duration,
CommandSource commandSource)
{
}
public Task CommandCanceledAsync(
IRelationalConnection connection,
DbCommand command,
DbContext? context,
DbCommandMethod executeMethod,
Guid commandId,
Guid connectionId,
DateTimeOffset startTime,
TimeSpan duration,
CommandSource commandSource,
CancellationToken cancellationToken = default)
=> Task.CompletedTask;
public InterceptionResult DataReaderDisposing(
IRelationalConnection connection,
DbCommand command,
......@@ -214,4 +240,4 @@ public bool ShouldLogCommandExecute(DateTimeOffset now)
public bool ShouldLogDataReaderDispose(DateTimeOffset now)
=> true;
}
\ No newline at end of file
}
using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.Storage.Internal;
using Microsoft.EntityFrameworkCore.Update.Internal;
using Npgsql.EntityFrameworkCore.PostgreSQL.Internal;
using Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal;
......@@ -27,7 +28,8 @@ public void Uses_MaxBatchSize_specified_in_NpgsqlOptionsExtension()
new ModificationCommandBatchFactoryDependencies(
new RelationalCommandBuilderFactory(
new RelationalCommandBuilderDependencies(
typeMapper)),
typeMapper,
new ExceptionDetector())),
new NpgsqlSqlGenerationHelper(
new RelationalSqlGenerationHelperDependencies()),
new NpgsqlUpdateSqlGenerator(
......@@ -66,7 +68,8 @@ public void MaxBatchSize_is_optional()
new ModificationCommandBatchFactoryDependencies(
new RelationalCommandBuilderFactory(
new RelationalCommandBuilderDependencies(
typeMapper)),
typeMapper,
new ExceptionDetector())),
new NpgsqlSqlGenerationHelper(
new RelationalSqlGenerationHelperDependencies()),
new NpgsqlUpdateSqlGenerator(
......@@ -104,4 +107,4 @@ private class FakeDbContext : DbContext
return modificationCommand;
}
}
\ No newline at end of file
}
using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.Storage.Internal;
using Microsoft.EntityFrameworkCore.Update.Internal;
using Npgsql.EntityFrameworkCore.PostgreSQL.Internal;
using Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal;
......@@ -25,7 +26,8 @@ public void AddCommand_returns_false_when_max_batch_size_is_reached()
new ModificationCommandBatchFactoryDependencies(
new RelationalCommandBuilderFactory(
new RelationalCommandBuilderDependencies(
typeMapper)),
typeMapper,
new ExceptionDetector())),
new NpgsqlSqlGenerationHelper(
new RelationalSqlGenerationHelperDependencies()),
new NpgsqlUpdateSqlGenerator(
......@@ -65,4 +67,4 @@ private class FakeDbContext : DbContext
return modificationCommand;
}
}
\ No newline at end of file
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册