Skip to content

Commit

Permalink
[fix]pgsql 字符串字段,入库时要进行转义。
Browse files Browse the repository at this point in the history
  • Loading branch information
Soar360 committed Sep 10, 2024
1 parent 2e8cdec commit 1636b3a
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions XCode/DataAccessLayer/Database/PostgreSQL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,12 @@ public override String FormatValue(IDataColumn field, Object? value)
if (field.DataType == typeof(String))
{
if (value == null) return field.Nullable ? "null" : "''";
//云飞扬:这里注释掉,应该返回``而不是null字符
//if (String.IsNullOrEmpty(value.ToString()) && field.Nullable) return "null";
return "'" + value + "'";
return "'" + value.ToString().Replace("'", "''") + "'";
}
else if (field.DataType == typeof(Boolean))
{
return (Boolean)value ? "true" : "false";
}

return base.FormatValue(field, value);
}

Expand Down

0 comments on commit 1636b3a

Please sign in to comment.