From 233990dfb5e6f06f73fc17ae26ed102051180432 Mon Sep 17 00:00:00 2001 From: 2881099 <2881099@qq.com> Date: Tue, 12 Nov 2024 09:17:34 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=BF=AE=E5=A4=8D=20GBase=20serial8/bigser?= =?UTF-8?q?ial=20=E8=87=AA=E5=A2=9E=E5=9B=9E=E5=A1=AB=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=9B#1919?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FreeSql.Provider.GBase/Curd/GBaseInsert.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Providers/FreeSql.Provider.GBase/Curd/GBaseInsert.cs b/Providers/FreeSql.Provider.GBase/Curd/GBaseInsert.cs index 880474745..3f7c9d7b9 100644 --- a/Providers/FreeSql.Provider.GBase/Curd/GBaseInsert.cs +++ b/Providers/FreeSql.Provider.GBase/Curd/GBaseInsert.cs @@ -42,12 +42,15 @@ protected override long RawExecuteIdentity() var sql = this.ToSql(); if (string.IsNullOrEmpty(sql)) return 0; - var identityType = _table.Primarys.Where(a => a.Attribute.IsIdentity).FirstOrDefault()?.CsType.NullableTypeOrThis(); + var identityCol = _table.Primarys.Where(a => a.Attribute.IsIdentity).FirstOrDefault(); + var identityType = identityCol?.Attribute.MapType.NullableTypeOrThis(); var identitySql = ""; if (identityType != null) { if (identityType == typeof(int) || identityType == typeof(uint)) identitySql = "SELECT dbinfo('sqlca.sqlerrd1') FROM dual"; - else if (identityType == typeof(long) || identityType == typeof(ulong)) identitySql = "SELECT dbinfo('serial8') FROM dual"; + else if (identityType == typeof(long) || identityType == typeof(ulong)) identitySql = + identityCol.Attribute.DbType.IndexOf("bigserial", StringComparison.OrdinalIgnoreCase) != -1 ? + "SELECT dbinfo('bigserial') FROM dual" : "SELECT dbinfo('serial8') FROM dual"; } var before = new Aop.CurdBeforeEventArgs(_table.Type, _table, Aop.CurdType.Insert, string.Concat(sql, $"; {identitySql};"), _params); _orm.Aop.CurdBeforeHandler?.Invoke(this, before); @@ -102,12 +105,15 @@ async protected override Task RawExecuteIdentityAsync(CancellationToken ca var sql = this.ToSql(); if (string.IsNullOrEmpty(sql)) return 0; - var identityType = _table.Primarys.Where(a => a.Attribute.IsIdentity).FirstOrDefault()?.CsType.NullableTypeOrThis(); + var identityCol = _table.Primarys.Where(a => a.Attribute.IsIdentity).FirstOrDefault(); + var identityType = identityCol?.Attribute.MapType.NullableTypeOrThis(); var identitySql = ""; if (identityType != null) { if (identityType == typeof(int) || identityType == typeof(uint)) identitySql = "SELECT dbinfo('sqlca.sqlerrd1') FROM dual"; - else if (identityType == typeof(long) || identityType == typeof(ulong)) identitySql = "SELECT dbinfo('serial8') FROM dual"; + else if (identityType == typeof(long) || identityType == typeof(ulong)) identitySql = + identityCol.Attribute.DbType.IndexOf("bigserial", StringComparison.OrdinalIgnoreCase) != -1 ? + "SELECT dbinfo('bigserial') FROM dual" : "SELECT dbinfo('serial8') FROM dual"; } var before = new Aop.CurdBeforeEventArgs(_table.Type, _table, Aop.CurdType.Insert, string.Concat(sql, $"; {identitySql};"), _params); _orm.Aop.CurdBeforeHandler?.Invoke(this, before);