-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Sync to EF 10.0.0-alpha.1.24620.1 (#3416)
Implement the new translation tests
Showing
24 changed files
with
5,346 additions
and
984 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"sdk": { | ||
"version": "9.0.100", | ||
"version": "10.0.100-alpha.1.24620.13", | ||
"rollForward": "latestMajor", | ||
"allowPrerelease": false | ||
"allowPrerelease": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
509 changes: 0 additions & 509 deletions
509
test/EFCore.PG.FunctionalTests/Query/GearsOfWarQueryNpgsqlTest.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
test/EFCore.PG.FunctionalTests/Query/Translations/BasicTypesQueryNpgsqlFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; | ||
using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure; | ||
using Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities; | ||
|
||
#nullable enable | ||
|
||
namespace Microsoft.EntityFrameworkCore.Query.Translations; | ||
|
||
public class BasicTypesQueryNpgsqlFixture : BasicTypesQueryFixtureBase, ITestSqlLoggerFactory | ||
{ | ||
private BasicTypesData? _expectedData; | ||
|
||
protected override ITestStoreFactory TestStoreFactory | ||
=> NpgsqlTestStoreFactory.Instance; | ||
|
||
public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) | ||
{ | ||
new NpgsqlDbContextOptionsBuilder(base.AddOptions(builder)).SetPostgresVersion(TestEnvironment.PostgresVersion); | ||
return builder; | ||
} | ||
|
||
protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) | ||
=> modelBuilder.HasPostgresExtension("uuid-ossp"); | ||
|
||
protected override Task SeedAsync(BasicTypesContext context) | ||
{ | ||
_expectedData ??= LoadAndTweakData(); | ||
context.AddRange(_expectedData.BasicTypesEntities); | ||
context.AddRange(_expectedData.NullableBasicTypesEntities); | ||
return context.SaveChangesAsync(); | ||
} | ||
|
||
public override ISetSource GetExpectedData() | ||
=> _expectedData ??= LoadAndTweakData(); | ||
|
||
private BasicTypesData LoadAndTweakData() | ||
{ | ||
var data = (BasicTypesData)base.GetExpectedData(); | ||
|
||
foreach (var item in data.BasicTypesEntities) | ||
{ | ||
// For all relevant temporal types, chop sub-microsecond precision which PostgreSQL does not support. | ||
// Temporal types which aren't set (default) get mapped to -infinity on PostgreSQL; this value causes many tests to fail. | ||
|
||
if (item.DateTime == default) | ||
{ | ||
item.DateTime += TimeSpan.FromSeconds(1); | ||
} | ||
|
||
// PostgreSQL maps DateTime to timestamptz by default, but that represents UTC timestamps which require DateTimeKind.Utc. | ||
item.DateTime = DateTime.SpecifyKind(new DateTime(StripSubMicrosecond(item.DateTime.Ticks)), DateTimeKind.Utc); | ||
|
||
if (item.DateOnly == default) | ||
{ | ||
item.DateOnly = item.DateOnly.AddDays(1); | ||
} | ||
|
||
item.TimeOnly = new TimeOnly(StripSubMicrosecond(item.TimeOnly.Ticks)); | ||
item.TimeSpan = new TimeSpan(StripSubMicrosecond(item.TimeSpan.Ticks)); | ||
|
||
if (item.DateTimeOffset == default) | ||
{ | ||
item.DateTimeOffset += TimeSpan.FromSeconds(1); | ||
} | ||
|
||
// PostgreSQL doesn't have a real DateTimeOffset type; we map .NET DateTimeOffset to timestamptz, which represents a UTC | ||
// timestamp, and so we only support offset=0. | ||
// Also chop sub-microsecond precision which PostgreSQL does not support. | ||
item.DateTimeOffset = new DateTimeOffset(StripSubMicrosecond(item.DateTimeOffset.Ticks), TimeSpan.Zero); | ||
} | ||
|
||
// Do the same for the nullable counterparts | ||
foreach (var item in data.NullableBasicTypesEntities) | ||
{ | ||
if (item.DateTime.HasValue) | ||
{ | ||
item.DateTime = DateTime.SpecifyKind(new DateTime(StripSubMicrosecond(item.DateTime.Value.Ticks)), DateTimeKind.Utc); | ||
} | ||
|
||
if (item.TimeOnly.HasValue) | ||
{ | ||
item.TimeOnly = new TimeOnly(StripSubMicrosecond(item.TimeOnly.Value.Ticks)); | ||
} | ||
|
||
if (item.TimeSpan.HasValue) | ||
{ | ||
item.TimeSpan = new TimeSpan(StripSubMicrosecond(item.TimeSpan.Value.Ticks)); | ||
} | ||
|
||
if (item.DateTimeOffset.HasValue) | ||
{ | ||
item.DateTimeOffset = new DateTimeOffset(StripSubMicrosecond(item.DateTimeOffset.Value.Ticks), TimeSpan.Zero); | ||
} | ||
} | ||
|
||
return data; | ||
|
||
static long StripSubMicrosecond(long ticks) => ticks - (ticks % (TimeSpan.TicksPerMillisecond / 1000)); | ||
} | ||
|
||
public TestSqlLoggerFactory TestSqlLoggerFactory | ||
=> (TestSqlLoggerFactory)ListLoggerFactory; | ||
} |
310 changes: 310 additions & 0 deletions
310
test/EFCore.PG.FunctionalTests/Query/Translations/EnumTranslationsNpgsqlTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,310 @@ | ||
namespace Microsoft.EntityFrameworkCore.Query.Translations; | ||
|
||
#nullable enable | ||
|
||
public class EnumTranslationsNpgsqlTest : EnumTranslationsTestBase<BasicTypesQueryNpgsqlFixture> | ||
{ | ||
public EnumTranslationsNpgsqlTest(BasicTypesQueryNpgsqlFixture fixture, ITestOutputHelper testOutputHelper) | ||
: base(fixture) | ||
{ | ||
Fixture.TestSqlLoggerFactory.Clear(); | ||
Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); | ||
} | ||
|
||
#region Equality | ||
|
||
public override async Task Equality_to_constant(bool async) | ||
{ | ||
await base.Equality_to_constant(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE b."Enum" = 0 | ||
"""); | ||
} | ||
|
||
public override async Task Equality_to_parameter(bool async) | ||
{ | ||
await base.Equality_to_parameter(async); | ||
|
||
AssertSql( | ||
""" | ||
@basicEnum='0' | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE b."Enum" = @basicEnum | ||
"""); | ||
} | ||
|
||
public override async Task Equality_nullable_enum_to_constant(bool async) | ||
{ | ||
await base.Equality_nullable_enum_to_constant(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT n."Id", n."Bool", n."Byte", n."ByteArray", n."DateOnly", n."DateTime", n."DateTimeOffset", n."Decimal", n."Double", n."Enum", n."FlagsEnum", n."Float", n."Guid", n."Int", n."Long", n."Short", n."String", n."TimeOnly", n."TimeSpan" | ||
FROM "NullableBasicTypesEntities" AS n | ||
WHERE n."Enum" = 0 | ||
"""); | ||
} | ||
|
||
public override async Task Equality_nullable_enum_to_parameter(bool async) | ||
{ | ||
await base.Equality_nullable_enum_to_parameter(async); | ||
|
||
AssertSql( | ||
""" | ||
@basicEnum='0' | ||
SELECT n."Id", n."Bool", n."Byte", n."ByteArray", n."DateOnly", n."DateTime", n."DateTimeOffset", n."Decimal", n."Double", n."Enum", n."FlagsEnum", n."Float", n."Guid", n."Int", n."Long", n."Short", n."String", n."TimeOnly", n."TimeSpan" | ||
FROM "NullableBasicTypesEntities" AS n | ||
WHERE n."Enum" = @basicEnum | ||
"""); | ||
} | ||
|
||
public override async Task Equality_nullable_enum_to_null_constant(bool async) | ||
{ | ||
await base.Equality_nullable_enum_to_null_constant(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT n."Id", n."Bool", n."Byte", n."ByteArray", n."DateOnly", n."DateTime", n."DateTimeOffset", n."Decimal", n."Double", n."Enum", n."FlagsEnum", n."Float", n."Guid", n."Int", n."Long", n."Short", n."String", n."TimeOnly", n."TimeSpan" | ||
FROM "NullableBasicTypesEntities" AS n | ||
WHERE n."Enum" IS NULL | ||
"""); | ||
} | ||
|
||
public override async Task Equality_nullable_enum_to_null_parameter(bool async) | ||
{ | ||
await base.Equality_nullable_enum_to_null_parameter(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT n."Id", n."Bool", n."Byte", n."ByteArray", n."DateOnly", n."DateTime", n."DateTimeOffset", n."Decimal", n."Double", n."Enum", n."FlagsEnum", n."Float", n."Guid", n."Int", n."Long", n."Short", n."String", n."TimeOnly", n."TimeSpan" | ||
FROM "NullableBasicTypesEntities" AS n | ||
WHERE n."Enum" IS NULL | ||
"""); | ||
} | ||
|
||
public override async Task Equality_nullable_enum_to_nullable_parameter(bool async) | ||
{ | ||
await base.Equality_nullable_enum_to_nullable_parameter(async); | ||
|
||
AssertSql( | ||
""" | ||
@basicEnum='0' (Nullable = true) | ||
SELECT n."Id", n."Bool", n."Byte", n."ByteArray", n."DateOnly", n."DateTime", n."DateTimeOffset", n."Decimal", n."Double", n."Enum", n."FlagsEnum", n."Float", n."Guid", n."Int", n."Long", n."Short", n."String", n."TimeOnly", n."TimeSpan" | ||
FROM "NullableBasicTypesEntities" AS n | ||
WHERE n."Enum" = @basicEnum | ||
"""); | ||
} | ||
|
||
#endregion Equality | ||
|
||
public override async Task Bitwise_and_enum_constant(bool async) | ||
{ | ||
await base.Bitwise_and_enum_constant(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE b."FlagsEnum" & 1 > 0 | ||
""", | ||
// | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE b."FlagsEnum" & 1 = 1 | ||
"""); | ||
} | ||
|
||
public override async Task Bitwise_and_integral_constant(bool async) | ||
{ | ||
await base.Bitwise_and_integral_constant(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE b."FlagsEnum" & 8 = 8 | ||
""", | ||
// | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE b."FlagsEnum"::bigint & 8 = 8 | ||
""", | ||
// | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE b."FlagsEnum"::smallint & 8 = 8 | ||
"""); | ||
} | ||
|
||
public override async Task Bitwise_and_nullable_enum_with_constant(bool async) | ||
{ | ||
await base.Bitwise_and_nullable_enum_with_constant(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT n."Id", n."Bool", n."Byte", n."ByteArray", n."DateOnly", n."DateTime", n."DateTimeOffset", n."Decimal", n."Double", n."Enum", n."FlagsEnum", n."Float", n."Guid", n."Int", n."Long", n."Short", n."String", n."TimeOnly", n."TimeSpan" | ||
FROM "NullableBasicTypesEntities" AS n | ||
WHERE n."FlagsEnum" & 8 > 0 | ||
"""); | ||
} | ||
|
||
public override async Task Where_bitwise_and_nullable_enum_with_null_constant(bool async) | ||
{ | ||
await base.Where_bitwise_and_nullable_enum_with_null_constant(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT n."Id", n."Bool", n."Byte", n."ByteArray", n."DateOnly", n."DateTime", n."DateTimeOffset", n."Decimal", n."Double", n."Enum", n."FlagsEnum", n."Float", n."Guid", n."Int", n."Long", n."Short", n."String", n."TimeOnly", n."TimeSpan" | ||
FROM "NullableBasicTypesEntities" AS n | ||
WHERE n."FlagsEnum" & NULL > 0 | ||
"""); | ||
} | ||
|
||
public override async Task Where_bitwise_and_nullable_enum_with_non_nullable_parameter(bool async) | ||
{ | ||
await base.Where_bitwise_and_nullable_enum_with_non_nullable_parameter(async); | ||
|
||
AssertSql( | ||
""" | ||
@flagsEnum='8' | ||
SELECT n."Id", n."Bool", n."Byte", n."ByteArray", n."DateOnly", n."DateTime", n."DateTimeOffset", n."Decimal", n."Double", n."Enum", n."FlagsEnum", n."Float", n."Guid", n."Int", n."Long", n."Short", n."String", n."TimeOnly", n."TimeSpan" | ||
FROM "NullableBasicTypesEntities" AS n | ||
WHERE n."FlagsEnum" & @flagsEnum > 0 | ||
"""); | ||
} | ||
|
||
public override async Task Where_bitwise_and_nullable_enum_with_nullable_parameter(bool async) | ||
{ | ||
await base.Where_bitwise_and_nullable_enum_with_nullable_parameter(async); | ||
|
||
AssertSql( | ||
""" | ||
@flagsEnum='8' (Nullable = true) | ||
SELECT n."Id", n."Bool", n."Byte", n."ByteArray", n."DateOnly", n."DateTime", n."DateTimeOffset", n."Decimal", n."Double", n."Enum", n."FlagsEnum", n."Float", n."Guid", n."Int", n."Long", n."Short", n."String", n."TimeOnly", n."TimeSpan" | ||
FROM "NullableBasicTypesEntities" AS n | ||
WHERE n."FlagsEnum" & @flagsEnum > 0 | ||
""", | ||
// | ||
""" | ||
SELECT n."Id", n."Bool", n."Byte", n."ByteArray", n."DateOnly", n."DateTime", n."DateTimeOffset", n."Decimal", n."Double", n."Enum", n."FlagsEnum", n."Float", n."Guid", n."Int", n."Long", n."Short", n."String", n."TimeOnly", n."TimeSpan" | ||
FROM "NullableBasicTypesEntities" AS n | ||
WHERE n."FlagsEnum" & NULL > 0 | ||
"""); | ||
} | ||
|
||
public override async Task Bitwise_or(bool async) | ||
{ | ||
await base.Bitwise_or(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE b."FlagsEnum" | 8 > 0 | ||
"""); | ||
} | ||
|
||
public override async Task Bitwise_projects_values_in_select(bool async) | ||
{ | ||
await base.Bitwise_projects_values_in_select(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT b."FlagsEnum" & 8 = 8 AS "BitwiseTrue", b."FlagsEnum" & 8 = 4 AS "BitwiseFalse", b."FlagsEnum" & 8 AS "BitwiseValue" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE b."FlagsEnum" & 8 = 8 | ||
LIMIT 1 | ||
"""); | ||
} | ||
|
||
public override async Task HasFlag(bool async) | ||
{ | ||
await base.HasFlag(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE b."FlagsEnum" & 8 = 8 | ||
""", | ||
// | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE b."FlagsEnum" & 12 = 12 | ||
""", | ||
// | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE b."FlagsEnum" & 8 = 8 | ||
""", | ||
// | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE b."FlagsEnum" & 8 = 8 | ||
""", | ||
// | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE 8 & b."FlagsEnum" = b."FlagsEnum" | ||
""", | ||
// | ||
""" | ||
SELECT b."FlagsEnum" & 8 = 8 AS "hasFlagTrue", b."FlagsEnum" & 4 = 4 AS "hasFlagFalse" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE b."FlagsEnum" & 8 = 8 | ||
LIMIT 1 | ||
"""); | ||
} | ||
|
||
public override async Task HasFlag_with_non_nullable_parameter(bool async) | ||
{ | ||
await base.HasFlag_with_non_nullable_parameter(async); | ||
|
||
AssertSql( | ||
""" | ||
@flagsEnum='8' | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE b."FlagsEnum" & @flagsEnum = @flagsEnum | ||
"""); | ||
} | ||
|
||
public override async Task HasFlag_with_nullable_parameter(bool async) | ||
{ | ||
await base.HasFlag_with_nullable_parameter(async); | ||
|
||
AssertSql( | ||
""" | ||
@flagsEnum='8' (Nullable = true) | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE b."FlagsEnum" & @flagsEnum = @flagsEnum | ||
"""); | ||
} | ||
|
||
[ConditionalFact] | ||
public virtual void Check_all_tests_overridden() | ||
=> TestHelpers.AssertAllMethodsOverridden(GetType()); | ||
|
||
private void AssertSql(params string[] expected) | ||
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected); | ||
} |
763 changes: 763 additions & 0 deletions
763
test/EFCore.PG.FunctionalTests/Query/Translations/MathTranslationsNpgsqlTest.cs
Large diffs are not rendered by default.
Oops, something went wrong.
517 changes: 517 additions & 0 deletions
517
test/EFCore.PG.FunctionalTests/Query/Translations/MiscellaneousTranslationsNpgsqlTest.cs
Large diffs are not rendered by default.
Oops, something went wrong.
203 changes: 203 additions & 0 deletions
203
test/EFCore.PG.FunctionalTests/Query/Translations/OperatorTranslationsNpgsqlTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
namespace Microsoft.EntityFrameworkCore.Query.Translations; | ||
|
||
public class OperatorTranslationsNpgsqlTest : OperatorTranslationsTestBase<BasicTypesQueryNpgsqlFixture> | ||
{ | ||
public OperatorTranslationsNpgsqlTest(BasicTypesQueryNpgsqlFixture fixture, ITestOutputHelper testOutputHelper) | ||
: base(fixture) | ||
{ | ||
Fixture.TestSqlLoggerFactory.Clear(); | ||
Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); | ||
} | ||
|
||
#region Bitwise | ||
|
||
public override async Task Bitwise_or(bool async) | ||
{ | ||
await base.Bitwise_or(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE b."Int"::bigint | b."Long" = 7 | ||
""", | ||
// | ||
""" | ||
SELECT b."Int"::bigint | b."Long" | ||
FROM "BasicTypesEntities" AS b | ||
"""); | ||
} | ||
|
||
public override async Task Bitwise_or_over_boolean(bool async) | ||
{ | ||
await base.Bitwise_or_over_boolean(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE b."Int" = 12 OR b."String" = 'Seattle' | ||
""", | ||
// | ||
""" | ||
SELECT b."Int" = 12 OR b."String" = 'Seattle' | ||
FROM "BasicTypesEntities" AS b | ||
"""); | ||
} | ||
|
||
public override async Task Bitwise_or_multiple(bool async) | ||
{ | ||
await base.Bitwise_or_multiple(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE CAST(b."Int" | b."Short" AS bigint) | b."Long" = 7 | ||
"""); | ||
} | ||
|
||
public override async Task Bitwise_and(bool async) | ||
{ | ||
await base.Bitwise_and(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE b."Int" & b."Short" = 2 | ||
""", | ||
// | ||
""" | ||
SELECT b."Int" & b."Short" | ||
FROM "BasicTypesEntities" AS b | ||
"""); | ||
} | ||
|
||
public override async Task Bitwise_and_over_boolean(bool async) | ||
{ | ||
await base.Bitwise_and_over_boolean(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE b."Int" = 8 AND b."String" = 'Seattle' | ||
""", | ||
// | ||
""" | ||
SELECT b."Int" = 8 AND b."String" = 'Seattle' | ||
FROM "BasicTypesEntities" AS b | ||
"""); | ||
} | ||
|
||
public override async Task Bitwise_xor(bool async) | ||
{ | ||
await base.Bitwise_xor(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE (b."Int" # b."Short") = 1 | ||
""", | ||
// | ||
""" | ||
SELECT b."Int" # b."Short" | ||
FROM "BasicTypesEntities" AS b | ||
"""); | ||
} | ||
|
||
public override async Task Bitwise_xor_over_boolean(bool async) | ||
{ | ||
await base.Bitwise_xor_over_boolean(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE (b."Int" = b."Short") <> (b."String" = 'Seattle') | ||
"""); | ||
} | ||
|
||
public override async Task Bitwise_complement(bool async) | ||
{ | ||
await base.Bitwise_complement(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE ~b."Int" = -9 | ||
"""); | ||
} | ||
|
||
public override async Task Bitwise_and_or_over_boolean(bool async) | ||
{ | ||
await base.Bitwise_and_or_over_boolean(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE (b."Int" = 12 AND b."Short" = 12) OR b."String" = 'Seattle' | ||
"""); | ||
} | ||
|
||
public override async Task Bitwise_or_with_logical_or(bool async) | ||
{ | ||
await base.Bitwise_or_with_logical_or(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE b."Int" = 12 OR b."Short" = 12 OR b."String" = 'Seattle' | ||
"""); | ||
} | ||
|
||
public override async Task Bitwise_and_with_logical_and(bool async) | ||
{ | ||
await base.Bitwise_and_with_logical_and(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE b."Int" = 8 AND b."Short" = 8 AND b."String" = 'Seattle' | ||
"""); | ||
} | ||
|
||
public override async Task Bitwise_or_with_logical_and(bool async) | ||
{ | ||
await base.Bitwise_or_with_logical_and(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE (b."Int" = 8 OR b."Short" = 9) AND b."String" = 'Seattle' | ||
"""); | ||
} | ||
|
||
public override async Task Bitwise_and_with_logical_or(bool async) | ||
{ | ||
await base.Bitwise_and_with_logical_or(async); | ||
|
||
AssertSql( | ||
""" | ||
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
FROM "BasicTypesEntities" AS b | ||
WHERE (b."Int" = 12 AND b."Short" = 12) OR b."String" = 'Seattle' | ||
"""); | ||
} | ||
|
||
#endregion Bitwise | ||
|
||
[ConditionalFact] | ||
public virtual void Check_all_tests_overridden() | ||
=> TestHelpers.AssertAllMethodsOverridden(GetType()); | ||
|
||
private void AssertSql(params string[] expected) | ||
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected); | ||
} |
1,505 changes: 1,505 additions & 0 deletions
1,505
test/EFCore.PG.FunctionalTests/Query/Translations/StringTranslationsNpgsqlTest.cs
Large diffs are not rendered by default.
Oops, something went wrong.
940 changes: 940 additions & 0 deletions
940
test/EFCore.PG.FunctionalTests/Query/Translations/TemporalTranslationsNpgsqlTest.cs
Large diffs are not rendered by default.
Oops, something went wrong.
997 changes: 997 additions & 0 deletions
997
...ctionalTests/Query/Translations/TemporalTranslationsNpgsqlTimestampWithoutTimeZoneTest.cs
Large diffs are not rendered by default.
Oops, something went wrong.