Skip to content

Commit

Permalink
Use C# 11 raw SQL literals for all SQL baselines (#29350)
Browse files Browse the repository at this point in the history
  • Loading branch information
roji committed Oct 15, 2022
1 parent 9b1c844 commit 7de5e80
Show file tree
Hide file tree
Showing 169 changed files with 53,400 additions and 28,397 deletions.
1 change: 1 addition & 0 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<PropertyGroup>
<NoWarn>$(NoWarn);CA1707;1591;xUnit1000;xUnit1003;xUnit1004;xUnit1010;xUnit1013;xUnit1026;xUnit2013;xUnit1024</NoWarn>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)..\rulesets\EFCore.test.ruleset</CodeAnalysisRuleSet>
<LangVersion>preview</LangVersion>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ public override void Object_to_string_conversion()
base.Object_to_string_conversion();

AssertSql(
@"SELECT c[""TestSignedByte""], c[""TestByte""], c[""TestInt16""], c[""TestUnsignedInt16""], c[""TestInt32""], c[""TestUnsignedInt32""], c[""TestInt64""], c[""TestUnsignedInt64""], c[""TestSingle""], c[""TestDouble""], c[""TestDecimal""], c[""TestCharacter""], c[""TestDateTime""], c[""TestDateTimeOffset""], c[""TestTimeSpan""]
"""
SELECT c["TestSignedByte"], c["TestByte"], c["TestInt16"], c["TestUnsignedInt16"], c["TestInt32"], c["TestUnsignedInt32"], c["TestInt64"], c["TestUnsignedInt64"], c["TestSingle"], c["TestDouble"], c["TestDecimal"], c["TestCharacter"], c["TestDateTime"], c["TestDateTimeOffset"], c["TestTimeSpan"]
FROM root c
WHERE ((c[""Discriminator""] = ""BuiltInDataTypes"") AND (c[""Id""] = 13))");
WHERE ((c["Discriminator"] = "BuiltInDataTypes") AND (c["Id"] = 13))
""");
}

private void AssertSql(params string[] expected)
Expand Down
24 changes: 16 additions & 8 deletions test/EFCore.Cosmos.FunctionalTests/CustomConvertersCosmosTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ public override void Where_bool_gets_converted_to_equality_when_value_conversion
base.Where_bool_gets_converted_to_equality_when_value_conversion_is_used();

AssertSql(
@"SELECT c
"""
SELECT c
FROM root c
WHERE (c[""Discriminator""] IN (""Blog"", ""RssBlog"") AND (c[""IsVisible""] = ""Y""))");
WHERE (c["Discriminator"] IN ("Blog", "RssBlog") AND (c["IsVisible"] = "Y"))
""");
}

[ConditionalFact]
Expand All @@ -82,9 +84,11 @@ public override void Where_negated_bool_gets_converted_to_equality_when_value_co
base.Where_negated_bool_gets_converted_to_equality_when_value_conversion_is_used();

AssertSql(
@"SELECT c
"""
SELECT c
FROM root c
WHERE (c[""Discriminator""] IN (""Blog"", ""RssBlog"") AND NOT((c[""IsVisible""] = ""Y"")))");
WHERE (c["Discriminator"] IN ("Blog", "RssBlog") AND NOT((c["IsVisible"] = "Y")))
""");
}

[ConditionalFact]
Expand All @@ -93,9 +97,11 @@ public override void Where_bool_gets_converted_to_equality_when_value_conversion
base.Where_bool_gets_converted_to_equality_when_value_conversion_is_used_using_EFProperty();

AssertSql(
@"SELECT c
"""
SELECT c
FROM root c
WHERE (c[""Discriminator""] IN (""Blog"", ""RssBlog"") AND (c[""IsVisible""] = ""Y""))");
WHERE (c["Discriminator"] IN ("Blog", "RssBlog") AND (c["IsVisible"] = "Y"))
""");
}

[ConditionalFact]
Expand All @@ -104,9 +110,11 @@ public override void Where_bool_gets_converted_to_equality_when_value_conversion
base.Where_bool_gets_converted_to_equality_when_value_conversion_is_used_using_indexer();

AssertSql(
@"SELECT c
"""
SELECT c
FROM root c
WHERE (c[""Discriminator""] IN (""Blog"", ""RssBlog"") AND NOT((c[""IndexerVisible""] = ""Aye"")))");
WHERE (c["Discriminator"] IN ("Blog", "RssBlog") AND NOT((c["IndexerVisible"] = "Aye")))
""");
}

[ConditionalFact(Skip = "Issue#27678")]
Expand Down
18 changes: 12 additions & 6 deletions test/EFCore.Cosmos.FunctionalTests/EndToEndCosmosTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1167,12 +1167,15 @@ public void Can_read_with_find_with_partition_key_without_value_generator()
Assert.Equal("Theon", customerFromStore.Name);
Assert.Equal(pk1, customerFromStore.PartitionKey);
AssertSql(
context, @"@__p_1='42'
context,
"""
@__p_1='42'

SELECT c
FROM root c
WHERE ((c[""Discriminator""] = ""Customer"") AND (c[""Id""] = @__p_1))
OFFSET 0 LIMIT 1");
WHERE ((c["Discriminator"] = "Customer") AND (c["Id"] = @__p_1))
OFFSET 0 LIMIT 1
""");

customerFromStore.Name = "Theon Greyjoy";

Expand Down Expand Up @@ -1297,12 +1300,15 @@ public async Task Can_read_with_find_with_PK_resource_id()
Assert.Equal("42", customerFromStore.id);
Assert.Equal("Theon", customerFromStore.Name);
AssertSql(
context, @"@__p_0='42'
context,
"""
@__p_0='42'

SELECT c
FROM root c
WHERE ((c[""Discriminator""] = ""CustomerWithResourceId"") AND (c[""id""] = @__p_0))
OFFSET 0 LIMIT 1");
WHERE ((c["Discriminator"] = "CustomerWithResourceId") AND (c["id"] = @__p_0))
OFFSET 0 LIMIT 1
""");
}
}

Expand Down
26 changes: 16 additions & 10 deletions test/EFCore.Cosmos.FunctionalTests/PartitionKeyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ public PartitionKeyTest(CosmosPartitionKeyFixture fixture)
public virtual async Task Can_add_update_delete_end_to_end_with_partition_key()
{
const string readSql =
@"SELECT c
"""
SELECT c
FROM root c
WHERE (c[""Discriminator""] = ""Customer"")
ORDER BY c[""PartitionKey""]
OFFSET 0 LIMIT 1";
WHERE (c["Discriminator"] = "Customer")
ORDER BY c["PartitionKey"]
OFFSET 0 LIMIT 1
""";

await PartitionKeyTestAsync(
ctx => ctx.Customers.OrderBy(c => c.PartitionKey).FirstAsync(),
Expand All @@ -43,10 +45,12 @@ await PartitionKeyTestAsync(
public virtual async Task Can_add_update_delete_end_to_end_with_with_partition_key_extension()
{
const string readSql =
@"SELECT c
"""
SELECT c
FROM root c
WHERE (c[""Discriminator""] = ""Customer"")
OFFSET 0 LIMIT 1";
WHERE (c["Discriminator"] = "Customer")
OFFSET 0 LIMIT 1
""";

await PartitionKeyTestAsync(
ctx => ctx.Customers.WithPartitionKey("1").FirstAsync(),
Expand All @@ -60,10 +64,12 @@ await PartitionKeyTestAsync(
public async Task Can_query_with_implicit_partition_key_filter()
{
const string readSql =
@"SELECT c
"""
SELECT c
FROM root c
WHERE ((c[""Discriminator""] = ""Customer"") AND ((c[""Id""] = 42) OR (c[""Name""] = ""John Snow"")))
OFFSET 0 LIMIT 1";
WHERE ((c["Discriminator"] = "Customer") AND ((c["Id"] = 42) OR (c["Name"] = "John Snow")))
OFFSET 0 LIMIT 1
""";

await PartitionKeyTestAsync(
ctx => ctx.Customers
Expand Down
Loading

0 comments on commit 7de5e80

Please sign in to comment.