From 2e8cdec0b3e84deb9aa911881c37e668ef816d35 Mon Sep 17 00:00:00 2001 From: Soar360 Date: Tue, 10 Sep 2024 16:20:57 +0800 Subject: [PATCH 1/3] =?UTF-8?q?[fix]pgsql=20=E5=A6=82=E6=9E=9C=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E8=A1=A8=E6=97=B6=EF=BC=8C=E4=B8=BB=E9=94=AE=E7=9A=84?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=90=8D=E4=B9=9F=E8=A6=81=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XCode/DataAccessLayer/Database/PostgreSQL.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/XCode/DataAccessLayer/Database/PostgreSQL.cs b/XCode/DataAccessLayer/Database/PostgreSQL.cs index ca3d60e68..ca39714e8 100644 --- a/XCode/DataAccessLayer/Database/PostgreSQL.cs +++ b/XCode/DataAccessLayer/Database/PostgreSQL.cs @@ -385,7 +385,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); From 1636b3accbd1d613e499646b23ee208e23507136 Mon Sep 17 00:00:00 2001 From: Soar360 Date: Tue, 10 Sep 2024 16:31:35 +0800 Subject: [PATCH 2/3] =?UTF-8?q?[fix]pgsql=20=E5=AD=97=E7=AC=A6=E4=B8=B2?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=EF=BC=8C=E5=85=A5=E5=BA=93=E6=97=B6=E8=A6=81?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E8=BD=AC=E4=B9=89=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XCode/DataAccessLayer/Database/PostgreSQL.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/XCode/DataAccessLayer/Database/PostgreSQL.cs b/XCode/DataAccessLayer/Database/PostgreSQL.cs index ca39714e8..25042b126 100644 --- a/XCode/DataAccessLayer/Database/PostgreSQL.cs +++ b/XCode/DataAccessLayer/Database/PostgreSQL.cs @@ -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); } From 84de516ce39f21ac4cd42e8b9d76a5ee00054d3a Mon Sep 17 00:00:00 2001 From: Soar360 Date: Tue, 10 Sep 2024 16:45:39 +0800 Subject: [PATCH 3/3] =?UTF-8?q?[fix]pgsql=20=E5=9C=A8=E8=BF=9B=E8=A1=8C=20?= =?UTF-8?q?InsertAndGetIdentity=20=E6=97=B6=EF=BC=8C=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E5=86=99=E6=AD=BB=20RETURNING=20id=EF=BC=8C?= =?UTF-8?q?=E5=9B=A0=E4=B8=BA=E8=87=AA=E5=A2=9E=E5=88=97=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E6=98=AF=E4=B8=8D=E5=9B=BA=E5=AE=9A=E7=9A=84=E3=80=82=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E7=9A=84=E5=81=9A=E6=B3=95=E6=98=AF=E5=B0=86=E8=87=AA?= =?UTF-8?q?=E5=A2=9E=E5=88=97=E9=80=9A=E8=BF=87=E5=8F=82=E6=95=B0=E4=BC=A0?= =?UTF-8?q?=E9=80=92=E8=BF=9B=E6=9D=A5=EF=BC=8C=E4=BD=86=E5=AF=B9=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=9A=84=E8=B0=83=E6=95=B4=E8=BE=83=E5=A4=A7=E3=80=82?= =?UTF-8?q?=E6=95=85=E5=8F=82=E7=85=A7=E4=BA=BA=E5=A4=A7=E9=87=91=E4=BB=93?= =?UTF-8?q?=E7=9A=84=E5=AE=9E=E7=8E=B0=EF=BC=8C=E4=BD=BF=E7=94=A8=20RETURN?= =?UTF-8?q?ING=20*=20=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XCode/DataAccessLayer/Database/PostgreSQL.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/XCode/DataAccessLayer/Database/PostgreSQL.cs b/XCode/DataAccessLayer/Database/PostgreSQL.cs index 25042b126..e708042d3 100644 --- a/XCode/DataAccessLayer/Database/PostgreSQL.cs +++ b/XCode/DataAccessLayer/Database/PostgreSQL.cs @@ -238,13 +238,13 @@ public override DbTable Query(SelectBuilder builder) /// 新增行的自动编号 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 InsertAndGetIdentityAsync(String sql, CommandType type = CommandType.Text, params IDataParameter[] ps) { - sql += " RETURNING id"; + sql = sql + $" RETURNING *"; return base.InsertAndGetIdentityAsync(sql, type, ps); }