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

no point concating single strings #721

Merged
merged 1 commit into from
Jan 13, 2021
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 @@ -234,7 +234,7 @@ public override string CreateInsert(QueryBuilder queryBuilder,

// Set the return value
var result = identityField != null ?
string.Concat($"LAST_INSERT_ID()") :
"LAST_INSERT_ID()" :
primaryField != null ? primaryField.Name.AsParameter(DbSetting) : "NULL";

builder
Expand Down Expand Up @@ -420,13 +420,13 @@ public override string CreateMerge(QueryBuilder queryBuilder,
// Check both primary and identity
if (identityField != null && !string.Equals(identityField.Name, primaryField.Name, StringComparison.OrdinalIgnoreCase))
{
result = string.Concat($"(CASE WHEN {identityField.Name.AsParameter(DbSetting)} > 0 THEN " +
result = $"(CASE WHEN {identityField.Name.AsParameter(DbSetting)} > 0 THEN " +
$"{identityField.Name.AsParameter(DbSetting)} ELSE " +
$"{primaryField.Name.AsParameter(DbSetting)} END)");
$"{primaryField.Name.AsParameter(DbSetting)} END)";
}
else
{
result = string.Concat($"COALESCE({primaryField.Name.AsParameter(DbSetting)}, LAST_INSERT_ID())");
result = $"COALESCE({primaryField.Name.AsParameter(DbSetting)}, LAST_INSERT_ID())";
}

// Build the query
Expand Down Expand Up @@ -546,13 +546,13 @@ public override string CreateMergeAll(QueryBuilder queryBuilder,
// Check both primary and identity
if (identityField != null && !string.Equals(identityField.Name, primaryField.Name, StringComparison.OrdinalIgnoreCase))
{
result = string.Concat($"(CASE WHEN {identityField.Name.AsParameter(index, DbSetting)} > 0 THEN " +
result = $"(CASE WHEN {identityField.Name.AsParameter(index, DbSetting)} > 0 THEN " +
$"{identityField.Name.AsParameter(index, DbSetting)} ELSE " +
$"{primaryField.Name.AsParameter(index, DbSetting)} END)");
$"{primaryField.Name.AsParameter(index, DbSetting)} END)";
}
else
{
result = string.Concat($"COALESCE({primaryField.Name.AsParameter(index, DbSetting)}, LAST_INSERT_ID())");
result = $"COALESCE({primaryField.Name.AsParameter(index, DbSetting)}, LAST_INSERT_ID())";
}

if (!string.IsNullOrEmpty(result))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public override string CreateInsert(QueryBuilder queryBuilder,

// Set the return value
var result = identityField != null ?
string.Concat($"LAST_INSERT_ID()") :
"LAST_INSERT_ID()" :
primaryField != null ? primaryField.Name.AsParameter(DbSetting) : "NULL";

builder
Expand Down Expand Up @@ -420,13 +420,13 @@ public override string CreateMerge(QueryBuilder queryBuilder,
// Check both primary and identity
if (identityField != null && !string.Equals(identityField.Name, primaryField.Name, StringComparison.OrdinalIgnoreCase))
{
result = string.Concat($"(CASE WHEN {identityField.Name.AsParameter(DbSetting)} > 0 THEN " +
result = $"(CASE WHEN {identityField.Name.AsParameter(DbSetting)} > 0 THEN " +
$"{identityField.Name.AsParameter(DbSetting)} ELSE " +
$"{primaryField.Name.AsParameter(DbSetting)} END)");
$"{primaryField.Name.AsParameter(DbSetting)} END)";
}
else
{
result = string.Concat($"COALESCE({primaryField.Name.AsParameter(DbSetting)}, LAST_INSERT_ID())");
result = $"COALESCE({primaryField.Name.AsParameter(DbSetting)}, LAST_INSERT_ID())";
}

// Build the query
Expand Down Expand Up @@ -546,13 +546,13 @@ public override string CreateMergeAll(QueryBuilder queryBuilder,
// Check both primary and identity
if (identityField != null && !string.Equals(identityField.Name, primaryField.Name, StringComparison.OrdinalIgnoreCase))
{
result = string.Concat($"(CASE WHEN {identityField.Name.AsParameter(index, DbSetting)} > 0 THEN " +
result = $"(CASE WHEN {identityField.Name.AsParameter(index, DbSetting)} > 0 THEN " +
$"{identityField.Name.AsParameter(index, DbSetting)} ELSE " +
$"{primaryField.Name.AsParameter(index, DbSetting)} END)");
$"{primaryField.Name.AsParameter(index, DbSetting)} END)";
}
else
{
result = string.Concat($"COALESCE({primaryField.Name.AsParameter(index, DbSetting)}, LAST_INSERT_ID())");
result = $"COALESCE({primaryField.Name.AsParameter(index, DbSetting)}, LAST_INSERT_ID())";
}

if (!string.IsNullOrEmpty(result))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public override string CreateInsert(QueryBuilder queryBuilder,
var result = identityField != null ?
string.IsNullOrEmpty(databaseType) ?
identityField.Name.AsQuoted(DbSetting) :
string.Concat($"CAST({identityField.Name.AsQuoted(DbSetting)} AS {databaseType})") :
$"CAST({identityField.Name.AsQuoted(DbSetting)} AS {databaseType})" :
primaryField != null ? primaryField.Name.AsQuoted(DbSetting) : "NULL";

// Get the string
Expand Down Expand Up @@ -276,7 +276,7 @@ public override string CreateInsertAll(QueryBuilder queryBuilder,
var returnValue = identityField != null ?
string.IsNullOrEmpty(databaseType) ?
identityField.Name.AsQuoted(DbSetting) :
string.Concat($"CAST({identityField.Name.AsQuoted(DbSetting)} AS {databaseType})") :
$"CAST({identityField.Name.AsQuoted(DbSetting)} AS {databaseType})" :
primaryField != null ? primaryField.Name.AsQuoted(DbSetting) : "NULL";
commandTexts.Add(string.Concat(line, " RETURNING ", returnValue, " AS ", "Id".AsQuoted(DbSetting), ", ",
$"{DbSetting.ParameterPrefix}__RepoDb_OrderColumn_{index} AS ", "OrderColumn".AsQuoted(DbSetting), " ;"));
Expand Down Expand Up @@ -398,7 +398,7 @@ public override string CreateMerge(QueryBuilder queryBuilder,
// Set the return value
var result = identityField == null ? primaryField.Name.AsParameter(DbSetting) :
string.IsNullOrEmpty(databaseType) ? identityField.Name.AsQuoted(DbSetting) :
string.Concat($"CAST({identityField.Name.AsQuoted(DbSetting)} AS {databaseType})");
$"CAST({identityField.Name.AsQuoted(DbSetting)} AS {databaseType})";

if (!string.IsNullOrEmpty(result))
{
Expand Down Expand Up @@ -502,7 +502,7 @@ public override string CreateMergeAll(QueryBuilder queryBuilder,
// Set the return value
var result = identityField == null ? primaryField.Name.AsParameter(DbSetting) :
string.IsNullOrEmpty(databaseType) ? identityField.Name.AsQuoted(DbSetting) :
string.Concat($"CAST({identityField.Name.AsQuoted(DbSetting)} AS {databaseType})");
$"CAST({identityField.Name.AsQuoted(DbSetting)} AS {databaseType})";

// Clear the builder
builder.Clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public override string CreateInsert(QueryBuilder queryBuilder,

// Set the return value
var result = identityField != null ?
string.Concat($"CAST(last_insert_rowid() AS {databaseType})") :
$"CAST(last_insert_rowid() AS {databaseType})" :
primaryField != null ? primaryField.Name.AsParameter(DbSetting) : "NULL";

builder
Expand Down