Merge pull request #1302 from MarsonShine/master

解决PGSQL10以前的自增长SERIAL和10之后的标准化写法GENERATED的兼容
This commit is contained in:
果糖网 2024-11-11 10:51:09 +08:00 committed by GitHub
commit 57311d37b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -30,8 +30,11 @@ namespace SqlSugar
col_description(pclass.oid, pcolumn.ordinal_position) as ColumnDescription,
case when pkey.colname = pcolumn.column_name
then true else false end as IsPrimaryKey,
case when pcolumn.column_default like 'nextval%'
then true else false end as IsIdentity,
CASE
WHEN (current_setting('server_version_num')::INT >= 100000 AND pcolumn.is_identity = 'YES') THEN true
WHEN pcolumn.column_default LIKE 'nextval%' THEN true
ELSE false
END AS IsIdentity,
case when pcolumn.is_nullable = 'YES'
then true else false end as IsNullable
from (select * from pg_tables where upper(tablename) = upper('{0}') and schemaname='" + schema + @"') ptables inner join pg_class pclass