Skip to content

Commit

Permalink
Update PostgreSqlStatementBuilder.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Jan 13, 2021
1 parent 16da93c commit bc7f263
Showing 1 changed file with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,29 +263,28 @@ public override string CreateInsertAll(QueryBuilder queryBuilder,
}
}

if (identityField != null)
{
// Variables needed
var commandTexts = new List<string>();
var splitted = commandText.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
// Variables needed
var commandTexts = new List<string>();
var splitted = commandText.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

// Iterate the indexes
for (var index = 0; index < splitted.Length; index++)
{
var line = splitted[index].Trim();
// Iterate the indexes
for (var index = 0; index < splitted.Length; index++)
{
var line = splitted[index].Trim();

// Set the return value
var returnValue = string.IsNullOrEmpty(databaseType) ?
// Set the return value
var returnValue = identityField != null ?
string.IsNullOrEmpty(databaseType) ?
identityField.Name.AsQuoted(DbSetting) :
string.Concat($"CAST({identityField.Name.AsQuoted(DbSetting)} AS {databaseType})");
commandTexts.Add(string.Concat(line, " RETURNING ", returnValue, " AS ", "Id".AsQuoted(DbSetting), ", ",
$"{DbSetting.ParameterPrefix}__RepoDb_OrderColumn_{index} AS ", "OrderColumn".AsQuoted(DbSetting), " ;"));
}

// Set the command text
commandText = commandTexts.Join(" ");
string.Concat($"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), " ;"));
}

// Set the command text
commandText = commandTexts.Join(" ");

// Return the query
return commandText;
}
Expand Down

0 comments on commit bc7f263

Please sign in to comment.