Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Sep 10, 2024
2 parents 747d6fa + 84de516 commit d0c4a90
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 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 Expand Up @@ -241,13 +238,13 @@ public override DbTable Query(SelectBuilder builder)
/// <returns>新增行的自动编号</returns>
public override Int64 InsertAndGetIdentity(String sql, CommandType type = CommandType.Text, params IDataParameter[] ps)
{
sql += " RETURNING id";
sql = sql + $" RETURNING *";
return base.InsertAndGetIdentity(sql, type, ps);
}

public override Task<Int64> InsertAndGetIdentityAsync(String sql, CommandType type = CommandType.Text, params IDataParameter[] ps)
{
sql += " RETURNING id";
sql = sql + $" RETURNING *";
return base.InsertAndGetIdentityAsync(sql, type, ps);
}

Expand Down Expand Up @@ -385,7 +382,7 @@ protected override void FixField(IDataColumn field, DataRow dr)

public override String FieldClause(IDataColumn field, Boolean onlyDefine)
{
if (field.Identity) return $"{field.Name} serial NOT NULL";
if (field.Identity) return $"{FormatName(field)} serial NOT NULL";

var sql = base.FieldClause(field, onlyDefine);

Expand Down

0 comments on commit d0c4a90

Please sign in to comment.