From caa40e76f2de1a64762ddd7fee8da57d8cfbc65b Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Thu, 14 Jan 2021 08:38:48 +1100 Subject: [PATCH] no point concating single strings --- .../StatementBuilders/MySqlStatementBuilder.cs | 14 +++++++------- .../MySqlConnectorStatementBuilder.cs | 14 +++++++------- .../PostgreSqlStatementBuilder.cs | 8 ++++---- .../StatementBuilders/SqLiteStatementBuilder.cs | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/RepoDb.MySql/RepoDb.MySql/StatementBuilders/MySqlStatementBuilder.cs b/RepoDb.MySql/RepoDb.MySql/StatementBuilders/MySqlStatementBuilder.cs index 2f8c0789b..be88f8dba 100644 --- a/RepoDb.MySql/RepoDb.MySql/StatementBuilders/MySqlStatementBuilder.cs +++ b/RepoDb.MySql/RepoDb.MySql/StatementBuilders/MySqlStatementBuilder.cs @@ -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 @@ -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 @@ -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)) diff --git a/RepoDb.MySqlConnector/RepoDb.MySqlConnector/StatementBuilders/MySqlConnectorStatementBuilder.cs b/RepoDb.MySqlConnector/RepoDb.MySqlConnector/StatementBuilders/MySqlConnectorStatementBuilder.cs index 82d54a47e..8fb7e1764 100644 --- a/RepoDb.MySqlConnector/RepoDb.MySqlConnector/StatementBuilders/MySqlConnectorStatementBuilder.cs +++ b/RepoDb.MySqlConnector/RepoDb.MySqlConnector/StatementBuilders/MySqlConnectorStatementBuilder.cs @@ -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 @@ -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 @@ -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)) diff --git a/RepoDb.PostgreSql/RepoDb.PostgreSql/StatementBuilders/PostgreSqlStatementBuilder.cs b/RepoDb.PostgreSql/RepoDb.PostgreSql/StatementBuilders/PostgreSqlStatementBuilder.cs index 96404b81d..51da42011 100644 --- a/RepoDb.PostgreSql/RepoDb.PostgreSql/StatementBuilders/PostgreSqlStatementBuilder.cs +++ b/RepoDb.PostgreSql/RepoDb.PostgreSql/StatementBuilders/PostgreSqlStatementBuilder.cs @@ -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 @@ -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), " ;")); @@ -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)) { @@ -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(); diff --git a/RepoDb.SqLite/RepoDb.SqLite/StatementBuilders/SqLiteStatementBuilder.cs b/RepoDb.SqLite/RepoDb.SqLite/StatementBuilders/SqLiteStatementBuilder.cs index 984b13872..dec09da05 100644 --- a/RepoDb.SqLite/RepoDb.SqLite/StatementBuilders/SqLiteStatementBuilder.cs +++ b/RepoDb.SqLite/RepoDb.SqLite/StatementBuilders/SqLiteStatementBuilder.cs @@ -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