Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ToString() on string columns added #29349

Merged
merged 1 commit into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public SqlServerObjectToStringTranslator(ISqlExpressionFactory sqlExpressionFact
return null;
}

if(instance.TypeMapping is not null && instance.TypeMapping.ClrType == typeof(string))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after if

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing this in #29522

{
return instance;
}

if (instance.Type == typeof(bool))
{
if (instance is ColumnExpression columnExpression && columnExpression.IsNullable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public SqliteObjectToStringTranslator(ISqlExpressionFactory sqlExpressionFactory
return null;
}

if (instance.TypeMapping is not null && instance.TypeMapping.ClrType == typeof(string))
{
return instance;
}

if (instance.Type == typeof(bool))
{
if (instance is ColumnExpression columnExpression && columnExpression.IsNullable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ public virtual Task ToString_guid_property_projection(bool async)
Assert.Equal(e.B.ToLower(), a.B.ToLower());
});

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task ToString_string_property_projection(bool async)
=> AssertQuery(
async,
ss => ss.Set<Weapon>().Select(w => w.Name.ToString()));

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task ToString_boolean_property_non_nullable(bool async)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3539,6 +3539,15 @@ FROM [Gears] AS [g]
ORDER BY [g].[SquadId], [g].[Nickname]");
}

public override async Task ToString_string_property_projection(bool async)
{
await base.ToString_string_property_projection(async);

AssertSql(@"SELECT [w].[Name]
FROM [Weapons] AS [w]");
}


public override async Task ToString_boolean_property_non_nullable(bool async)
{
await base.ToString_boolean_property_non_nullable(async);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11307,6 +11307,14 @@ FROM [Weapons] AS [w]
ORDER BY [t].[Id], [t2].[Nickname], [t2].[FullName], [t2].[HasSoulPatch]");
}

public override async Task ToString_string_property_projection(bool async)
{
await base.ToString_string_property_projection(async);

AssertSql(@"SELECT [w].[Name]
FROM [Weapons] AS [w]");
}

public override async Task ToString_boolean_property_non_nullable(bool async)
{
await base.ToString_boolean_property_non_nullable(async);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9540,6 +9540,14 @@ FROM [Weapons] AS [w]
ORDER BY [t].[Id], [t1].[Nickname], [t1].[FullName], [t1].[HasSoulPatch]");
}

public override async Task ToString_string_property_projection(bool async)
{
await base.ToString_string_property_projection(async);

AssertSql(@"SELECT [w].[Name]
FROM [Weapons] AS [w]");
}

public override async Task ToString_boolean_property_non_nullable(bool async)
{
await base.ToString_boolean_property_non_nullable(async);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7838,6 +7838,14 @@ ELSE NULL
CROSS JOIN [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0]");
}

public override async Task ToString_string_property_projection(bool async)
{
await base.ToString_string_property_projection(async);

AssertSql(@"SELECT [w].[Name]
FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w]");
}

public override async Task ToString_boolean_property_non_nullable(bool async)
{
await base.ToString_boolean_property_non_nullable(async);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2731,6 +2731,14 @@ public override async Task Sum_with_optional_navigation_is_translated_to_sql(boo
WHERE ""t"".""Note"" <> 'Foo' OR (""t"".""Note"" IS NULL)");
}

public override async Task ToString_string_property_projection(bool async)
{
await base.ToString_string_property_projection(async);

AssertSql(@"SELECT ""w"".""Name""
FROM ""Weapons"" AS ""w""");
}

public override async Task ToString_boolean_property_non_nullable(bool async)
{
await base.ToString_boolean_property_non_nullable(async);
Expand Down