Skip to content
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 @@ -228,56 +228,36 @@ private static bool ShouldShowDbType(bool hasValue, DbType dbType, Type? type)

type = type.UnwrapNullableType().UnwrapEnumType();

switch (dbType)
return dbType switch
{
case DbType.Binary:
return type != typeof(byte[]);
case DbType.Byte:
return type != typeof(byte);
case DbType.Boolean:
return type != typeof(bool);
case DbType.Decimal:
return type != typeof(decimal);
case DbType.Double:
return type != typeof(double);
case DbType.Guid:
return type != typeof(Guid);
case DbType.Int16:
return type != typeof(short);
case DbType.Int32:
return type != typeof(int);
case DbType.Int64:
return type != typeof(long);
case DbType.Object:
return type != typeof(object);
case DbType.SByte:
return type != typeof(sbyte);
case DbType.Single:
return type != typeof(float);
case DbType.String:
return type != typeof(string);
case DbType.Time:
return type != typeof(TimeSpan);
case DbType.UInt16:
return type != typeof(ushort);
case DbType.UInt32:
return type != typeof(uint);
case DbType.UInt64:
return type != typeof(ulong);
case DbType.DateTime2:
return type != typeof(DateTime);
case DbType.DateTimeOffset:
return type != typeof(DateTimeOffset);
//case DbType.AnsiString:
//case DbType.VarNumeric:
//case DbType.AnsiStringFixedLength:
//case DbType.StringFixedLength:
//case DbType.Xml:
//case DbType.Currency:
//case DbType.Date:
//case DbType.DateTime:
default:
return true;
}
DbType.Binary => type != typeof(byte[]),
DbType.Byte => type != typeof(byte),
DbType.Boolean => type != typeof(bool),
DbType.Decimal => type != typeof(decimal),
DbType.Double => type != typeof(double),
DbType.Guid => type != typeof(Guid),
DbType.Int16 => type != typeof(short),
DbType.Int32 => type != typeof(int),
DbType.Int64 => type != typeof(long),
DbType.Object => type != typeof(object),
DbType.SByte => type != typeof(sbyte),
DbType.Single => type != typeof(float),
DbType.String => type != typeof(string),
DbType.Time => type != typeof(TimeSpan),
DbType.UInt16 => type != typeof(ushort),
DbType.UInt32 => type != typeof(uint),
DbType.UInt64 => type != typeof(ulong),
DbType.DateTime2 => type != typeof(DateTime),
DbType.DateTimeOffset => type != typeof(DateTimeOffset),
//DbType.AnsiString =>
//DbType.VarNumeric =>
//DbType.AnsiStringFixedLength =>
//DbType.StringFixedLength =>
//DbType.Xml =>
//DbType.Currency =>
//DbType.Date =>
//DbType.DateTime =>
_ => true,
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,9 @@ protected override void UnsafeLog<TState>(
TState state,
Exception? exception)
{
if ((eventId.Id == RelationalEventId.CommandExecuted.Id
|| eventId.Id == RelationalEventId.CommandError.Id
|| eventId.Id == RelationalEventId.CommandExecuting.Id))
if (eventId.Id == RelationalEventId.CommandExecuted.Id
|| eventId.Id == RelationalEventId.CommandError.Id
|| eventId.Id == RelationalEventId.CommandExecuting.Id)
{
if (_shouldLogCommands)
{
Expand All @@ -347,30 +347,21 @@ protected override void UnsafeLog<TState>(

_stringBuilder.Clear();

var inQuotes = false;
var inCurlies = false;
for (var i = 0; i < parameters.Length; i++)
{
var c = parameters[i];
switch (c)
if (c == ','
&& TryGetChar(parameters, i + 1, out var nextChar1) && nextChar1 == ' '
&& TryGetChar(parameters, i - 1, out var prevChar1)
&& (prevChar1 == '\'' || prevChar1 == ')'
// handles NULL (matching only 'LL' as "good enough")
|| (prevChar1 == 'L' && TryGetChar(parameters, i - 2, out var prevChar2) && prevChar2 == 'L')))
{
case '\'':
inQuotes = !inQuotes;
goto default;
case '{':
inCurlies = true;
goto default;
case '}':
inCurlies = false;
goto default;
case ',' when parameters[i + 1] == ' ' && !inQuotes && !inCurlies:
_stringBuilder.Append(_eol);
i++;
continue;
default:
_stringBuilder.Append(c);
continue;
_stringBuilder.Append(_eol);
i++;
continue;
}
_stringBuilder.Append(c);
}

_stringBuilder.Append(_eol).Append(_eol);
Expand All @@ -384,6 +375,17 @@ protected override void UnsafeLog<TState>(
{
base.UnsafeLog(logLevel, eventId, message, state, exception);
}

static bool TryGetChar(string s, int index, out char c)
{
if (index < 0 || index >= s.Length)
{
c = default;
return false;
}
c = s[index];
return true;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,8 @@ public override async Task Non_unicode_string_literals_in_contains_is_used_for_n
AssertSql(
"""
@cities1='Unknown' (Size = 100) (DbType = AnsiString)
@cities2='Jacinto's location' (Size = 100) (DbType = AnsiString), @cities3='Ephyra's location' (Size = 100) (DbType = AnsiString)
@cities2='Jacinto's location' (Size = 100) (DbType = AnsiString)
@cities3='Ephyra's location' (Size = 100) (DbType = AnsiString)

SELECT [c].[Name], [c].[Location], [c].[Nation]
FROM [Cities] AS [c]
Expand Down Expand Up @@ -8451,7 +8452,8 @@ public override async Task Parameter_used_multiple_times_take_appropriate_inferr

AssertSql(
"""
@place='Ephyra's location' (Size = 4000), @place0='Ephyra's location' (Size = 100) (DbType = AnsiString)
@place='Ephyra's location' (Size = 4000)
@place0='Ephyra's location' (Size = 100) (DbType = AnsiString)

SELECT [c].[Name], [c].[Location], [c].[Nation]
FROM [Cities] AS [c]
Expand Down Expand Up @@ -9150,7 +9152,8 @@ public override async Task Nav_expansion_with_member_pushdown_inside_Contains_ar

AssertSql(
"""
@weapons1='Marcus' Lancer' (Size = 4000), @weapons2='Dom's Gnasher' (Size = 4000)
@weapons1='Marcus' Lancer' (Size = 4000)
@weapons2='Dom's Gnasher' (Size = 4000)

SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank]
FROM [Gears] AS [g]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2421,7 +2421,8 @@ public override async Task Non_unicode_string_literals_in_contains_is_used_for_n
AssertSql(
"""
@cities1='Unknown' (Size = 100) (DbType = AnsiString)
@cities2='Jacinto's location' (Size = 100) (DbType = AnsiString), @cities3='Ephyra's location' (Size = 100) (DbType = AnsiString)
@cities2='Jacinto's location' (Size = 100) (DbType = AnsiString)
@cities3='Ephyra's location' (Size = 100) (DbType = AnsiString)

SELECT [c].[Name], [c].[Location], [c].[Nation]
FROM [Cities] AS [c]
Expand Down Expand Up @@ -10883,7 +10884,8 @@ public override async Task Parameter_used_multiple_times_take_appropriate_inferr

AssertSql(
"""
@place='Ephyra's location' (Size = 4000), @place0='Ephyra's location' (Size = 100) (DbType = AnsiString)
@place='Ephyra's location' (Size = 4000)
@place0='Ephyra's location' (Size = 100) (DbType = AnsiString)

SELECT [c].[Name], [c].[Location], [c].[Nation]
FROM [Cities] AS [c]
Expand Down Expand Up @@ -12226,7 +12228,8 @@ public override async Task Nav_expansion_with_member_pushdown_inside_Contains_ar

AssertSql(
"""
@weapons1='Marcus' Lancer' (Size = 4000), @weapons2='Dom's Gnasher' (Size = 4000)
@weapons1='Marcus' Lancer' (Size = 4000)
@weapons2='Dom's Gnasher' (Size = 4000)

SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator]
FROM (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2080,7 +2080,8 @@ public override async Task Non_unicode_string_literals_in_contains_is_used_for_n
AssertSql(
"""
@cities1='Unknown' (Size = 100) (DbType = AnsiString)
@cities2='Jacinto's location' (Size = 100) (DbType = AnsiString), @cities3='Ephyra's location' (Size = 100) (DbType = AnsiString)
@cities2='Jacinto's location' (Size = 100) (DbType = AnsiString)
@cities3='Ephyra's location' (Size = 100) (DbType = AnsiString)

SELECT [c].[Name], [c].[Location], [c].[Nation]
FROM [Cities] AS [c]
Expand Down Expand Up @@ -9195,7 +9196,8 @@ public override async Task Parameter_used_multiple_times_take_appropriate_inferr

AssertSql(
"""
@place='Ephyra's location' (Size = 4000), @place0='Ephyra's location' (Size = 100) (DbType = AnsiString)
@place='Ephyra's location' (Size = 4000)
@place0='Ephyra's location' (Size = 100) (DbType = AnsiString)

SELECT [c].[Name], [c].[Location], [c].[Nation]
FROM [Cities] AS [c]
Expand Down Expand Up @@ -10376,7 +10378,8 @@ public override async Task Nav_expansion_with_member_pushdown_inside_Contains_ar

AssertSql(
"""
@weapons1='Marcus' Lancer' (Size = 4000), @weapons2='Dom's Gnasher' (Size = 4000)
@weapons1='Marcus' Lancer' (Size = 4000)
@weapons2='Dom's Gnasher' (Size = 4000)

SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE
WHEN [o].[Nickname] IS NOT NULL THEN N'Officer'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2913,7 +2913,8 @@ public override async Task Parameter_used_multiple_times_take_appropriate_inferr

AssertSql(
"""
@place='Ephyra's location' (Size = 4000), @place0='Ephyra's location' (Size = 100) (DbType = AnsiString)
@place='Ephyra's location' (Size = 4000)
@place0='Ephyra's location' (Size = 100) (DbType = AnsiString)

SELECT [c].[Name], [c].[Location], [c].[Nation], [c].[PeriodEnd], [c].[PeriodStart]
FROM [Cities] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [c]
Expand Down Expand Up @@ -5915,7 +5916,8 @@ public override async Task Non_unicode_string_literals_in_contains_is_used_for_n
AssertSql(
"""
@cities1='Unknown' (Size = 100) (DbType = AnsiString)
@cities2='Jacinto's location' (Size = 100) (DbType = AnsiString), @cities3='Ephyra's location' (Size = 100) (DbType = AnsiString)
@cities2='Jacinto's location' (Size = 100) (DbType = AnsiString)
@cities3='Ephyra's location' (Size = 100) (DbType = AnsiString)

SELECT [c].[Name], [c].[Location], [c].[Nation], [c].[PeriodEnd], [c].[PeriodStart]
FROM [Cities] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [c]
Expand Down Expand Up @@ -9047,7 +9049,8 @@ public override async Task Nav_expansion_with_member_pushdown_inside_Contains_ar

AssertSql(
"""
@weapons1='Marcus' Lancer' (Size = 4000), @weapons2='Dom's Gnasher' (Size = 4000)
@weapons1='Marcus' Lancer' (Size = 4000)
@weapons2='Dom's Gnasher' (Size = 4000)

SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[PeriodEnd], [g].[PeriodStart], [g].[Rank]
FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,8 @@ public override async Task Non_unicode_string_literals_in_contains_is_used_for_n
AssertSql(
"""
@cities1='Unknown' (Size = 7)
@cities2='Jacinto's location' (Size = 18), @cities3='Ephyra's location' (Size = 17)
@cities2='Jacinto's location' (Size = 18)
@cities3='Ephyra's location' (Size = 17)

SELECT "c"."Name", "c"."Location", "c"."Nation"
FROM "Cities" AS "c"
Expand Down Expand Up @@ -8709,7 +8710,8 @@ public override async Task Nav_expansion_with_member_pushdown_inside_Contains_ar

AssertSql(
"""
@weapons1='Marcus' Lancer' (Size = 14), @weapons2='Dom's Gnasher' (Size = 13)
@weapons1='Marcus' Lancer' (Size = 14)
@weapons2='Dom's Gnasher' (Size = 13)

SELECT "g"."Nickname", "g"."SquadId", "g"."AssignedCityName", "g"."CityOfBirthName", "g"."Discriminator", "g"."FullName", "g"."HasSoulPatch", "g"."LeaderNickname", "g"."LeaderSquadId", "g"."Rank"
FROM "Gears" AS "g"
Expand Down
Loading