Skip to content

Commit

Permalink
pgsql 改用 ref 传参优化 FormatValue 方法
Browse files Browse the repository at this point in the history
  • Loading branch information
Soar360 committed Sep 29, 2024
1 parent 669f1c2 commit 07f7d3e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions XCode/DataAccessLayer/Database/PostgreSQL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public override String FormatValue(IDataColumn? column, Object? value)
builder.Append("ARRAY[");
foreach (var v in (IEnumerable)value)
{
builder.Append(ValueToSQL(type, isNullable, v, out fieldType));
builder.Append(ValueToSQL(type, isNullable, v, ref fieldType));
builder.Append(',');
count++;
}
Expand All @@ -146,17 +146,16 @@ public override String FormatValue(IDataColumn? column, Object? value)
}
else
{
return ValueToSQL(type, isNullable, value, out fieldType);
return ValueToSQL(type, isNullable, value, ref fieldType);
}
}


private string ValueToSQL(Type? type, bool isNullable, object? value, out string fieldType)
private string ValueToSQL(Type? type, bool isNullable, object? value, ref string fieldType)
{
fieldType = string.Empty;
if (type == typeof(String))
{
fieldType = "varchar";
if (string.IsNullOrWhiteSpace(fieldType)) fieldType = "varchar";
if (value is null) return isNullable ? "null" : "''";
return "'" + value.ToString().Replace("'", "''") + "'";
}
Expand Down

0 comments on commit 07f7d3e

Please sign in to comment.