From 1d09b7fba37d3bfb385c9d01e9ce1a94578d1400 Mon Sep 17 00:00:00 2001 From: 28810 <28810@YEXIANGQIN> Date: Thu, 2 Apr 2020 13:27:37 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=BF=AE=E5=A4=8D=20PostgreSQL=20CodeFirst?= =?UTF-8?q?/DbFirst=20=E7=B3=BB=E7=BB=9F=E8=A1=A8=E7=9A=84=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=85=BC=E5=AE=B9=E9=97=AE=E9=A2=98=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PostgreSQL/OdbcPostgreSQLCodeFirst.cs | 4 ++-- .../PostgreSQL/OdbcPostgreSQLDbFirst.cs | 6 +++--- .../FreeSql.Provider.PostgreSQL/PostgreSQLCodeFirst.cs | 4 ++-- Providers/FreeSql.Provider.PostgreSQL/PostgreSQLDbFirst.cs | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Providers/FreeSql.Provider.Odbc/PostgreSQL/OdbcPostgreSQLCodeFirst.cs b/Providers/FreeSql.Provider.Odbc/PostgreSQL/OdbcPostgreSQLCodeFirst.cs index bbc2d5e9..382de62f 100644 --- a/Providers/FreeSql.Provider.Odbc/PostgreSQL/OdbcPostgreSQLCodeFirst.cs +++ b/Providers/FreeSql.Provider.Odbc/PostgreSQL/OdbcPostgreSQLCodeFirst.cs @@ -182,8 +182,8 @@ t.typname, case when a.atttypmod > 0 and a.atttypmod < 32767 then a.atttypmod - 4 else a.attlen end len, case when t.typelem > 0 and t.typinput::varchar = 'array_in' then t2.typname else t.typname end, case when a.attnotnull then '0' else '1' end as is_nullable, -coalesce((select 1 from pg_sequences where lower(sequencename) = lower({0} || '_' || {1} || '_' || a.attname || '_sequence_name') limit 1),0) is_identity, --e.adsrc, +(select pg_get_expr(adbin, adrelid) from pg_attrdef where adrelid = e.adrelid) is_identity, a.attndims, d.description as comment from pg_class c @@ -219,7 +219,7 @@ where ns.nspname = {0} and c.relname = {1}", tboldname ?? tbname); sqlType = string.Concat(sqlType), max_length = long.Parse(string.Concat(a[2])), is_nullable = string.Concat(a[4]) == "1", - is_identity = string.Concat(a[5]) == "1", //string.Concat(a[5]).StartsWith(@"nextval('") && string.Concat(a[5]).EndsWith(@"'::regclass)"), + is_identity = string.Concat(a[5]).StartsWith(@"nextval('") && string.Concat(a[5]).EndsWith(@"'::regclass)"), attndims, comment = string.Concat(a[7]) }; diff --git a/Providers/FreeSql.Provider.Odbc/PostgreSQL/OdbcPostgreSQLDbFirst.cs b/Providers/FreeSql.Provider.Odbc/PostgreSQL/OdbcPostgreSQLDbFirst.cs index 913ae1c3..db21a33f 100644 --- a/Providers/FreeSql.Provider.Odbc/PostgreSQL/OdbcPostgreSQLDbFirst.cs +++ b/Providers/FreeSql.Provider.Odbc/PostgreSQL/OdbcPostgreSQLDbFirst.cs @@ -209,8 +209,8 @@ t.typname, case when a.atttypmod > 0 and a.atttypmod < 32767 then a.atttypmod - 4 else a.attlen end len, case when t.typelem = 0 then t.typname else t2.typname end, case when a.attnotnull then 0 else 1 end as is_nullable, -coalesce((select 1 from pg_sequences where lower(sequencename) = lower({0} || '_' || {1} || '_' || a.attname || '_sequence_name') limit 1),0) is_identity, ---e.adsrc as is_identity, +--e.adsrc as is_identity, pg12以下 +(select pg_get_expr(adbin, adrelid) from pg_attrdef where adrelid = e.adrelid) is_identity, d.description as comment, a.attndims, case when t.typelem = 0 then t.typtype else t2.typtype end, @@ -236,7 +236,7 @@ where {loc8.ToString().Replace("a.table_name", "ns.nspname || '.' || c.relname") var max_length = int.Parse(string.Concat(row[3])); var sqlType = string.Concat(row[4]); var is_nullable = string.Concat(row[5]) == "1"; - var is_identity = string.Concat(row[6]) == "1"; //string.Concat(row[6]).StartsWith(@"nextval('") && string.Concat(row[6]).EndsWith(@"'::regclass)"); + var is_identity = string.Concat(row[6]).StartsWith(@"nextval('") && string.Concat(row[6]).EndsWith(@"'::regclass)"); var comment = string.Concat(row[7]); int attndims = int.Parse(string.Concat(row[8])); string typtype = string.Concat(row[9]); diff --git a/Providers/FreeSql.Provider.PostgreSQL/PostgreSQLCodeFirst.cs b/Providers/FreeSql.Provider.PostgreSQL/PostgreSQLCodeFirst.cs index e5a65693..ba8f6671 100644 --- a/Providers/FreeSql.Provider.PostgreSQL/PostgreSQLCodeFirst.cs +++ b/Providers/FreeSql.Provider.PostgreSQL/PostgreSQLCodeFirst.cs @@ -217,8 +217,8 @@ t.typname, case when a.atttypmod > 0 and a.atttypmod < 32767 then a.atttypmod - 4 else a.attlen end len, case when t.typelem > 0 and t.typinput::varchar = 'array_in' then t2.typname else t.typname end, case when a.attnotnull then '0' else '1' end as is_nullable, -coalesce((select 1 from pg_sequences where lower(sequencename) = lower({0} || '_' || {1} || '_' || a.attname || '_sequence_name') limit 1),0) is_identity, --e.adsrc, +(select pg_get_expr(adbin, adrelid) from pg_attrdef where adrelid = e.adrelid) is_identity, a.attndims, d.description as comment from pg_class c @@ -254,7 +254,7 @@ where ns.nspname = {0} and c.relname = {1}", tboldname ?? tbname); sqlType = string.Concat(sqlType), max_length = long.Parse(string.Concat(a[2])), is_nullable = string.Concat(a[4]) == "1", - is_identity = string.Concat(a[5]) == "1", //string.Concat(a[5]).StartsWith(@"nextval('") && string.Concat(a[5]).EndsWith(@"'::regclass)"), + is_identity = string.Concat(a[5]).StartsWith(@"nextval('") && string.Concat(a[5]).EndsWith(@"'::regclass)"), attndims, comment = string.Concat(a[7]) }; diff --git a/Providers/FreeSql.Provider.PostgreSQL/PostgreSQLDbFirst.cs b/Providers/FreeSql.Provider.PostgreSQL/PostgreSQLDbFirst.cs index eb586c98..29c93a20 100644 --- a/Providers/FreeSql.Provider.PostgreSQL/PostgreSQLDbFirst.cs +++ b/Providers/FreeSql.Provider.PostgreSQL/PostgreSQLDbFirst.cs @@ -319,8 +319,8 @@ t.typname, case when a.atttypmod > 0 and a.atttypmod < 32767 then a.atttypmod - 4 else a.attlen end len, case when t.typelem = 0 then t.typname else t2.typname end, case when a.attnotnull then 0 else 1 end as is_nullable, -coalesce((select 1 from pg_sequences where lower(sequencename) = lower({0} || '_' || {1} || '_' || a.attname || '_sequence_name') limit 1),0) is_identity, ---e.adsrc as is_identity, +--e.adsrc as is_identity, pg12以下 +(select pg_get_expr(adbin, adrelid) from pg_attrdef where adrelid = e.adrelid) is_identity, d.description as comment, a.attndims, case when t.typelem = 0 then t.typtype else t2.typtype end, @@ -346,7 +346,7 @@ where {loc8.ToString().Replace("a.table_name", "ns.nspname || '.' || c.relname") var max_length = int.Parse(string.Concat(row[3])); var sqlType = string.Concat(row[4]); var is_nullable = string.Concat(row[5]) == "1"; - var is_identity = string.Concat(row[6]) == "1"; //string.Concat(row[6]).StartsWith(@"nextval('") && string.Concat(row[6]).EndsWith(@"'::regclass)"); + var is_identity = string.Concat(row[6]).StartsWith(@"nextval('") && string.Concat(row[6]).EndsWith(@"'::regclass)"); var comment = string.Concat(row[7]); int attndims = int.Parse(string.Concat(row[8])); string typtype = string.Concat(row[9]);