mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 09:15:27 +08:00 
			
		
		
		
	局部调整
This commit is contained in:
		@@ -113,15 +113,15 @@ namespace FreeSql.MySql {
 | 
			
		||||
					var tboldname = tb.DbOldName?.Split(new[] { '.' }, 2); //旧表名
 | 
			
		||||
					if (tboldname?.Length == 1) tboldname = new[] { database, tboldname[0] };
 | 
			
		||||
 | 
			
		||||
					if (string.Compare(tbname[0], database, true) != 0 && ExecuteScalar(database, " select 1 from pg_database where datname={0}".FormatMySql(tbname[0])) == null) //创建数据库
 | 
			
		||||
					if (string.Compare(tbname[0], database, true) != 0 && ExecuteScalar(database, _commonUtils.FormatSql(" select 1 from pg_database where datname={0}", tbname[0])) == null) //创建数据库
 | 
			
		||||
						sb.Append($"CREATE DATABASE IF NOT EXISTS ").Append(_commonUtils.QuoteSqlName(tbname[0])).Append(" default charset utf8 COLLATE utf8_general_ci;\r\n");
 | 
			
		||||
 | 
			
		||||
					var sbalter = new StringBuilder();
 | 
			
		||||
					var istmpatler = false; //创建临时表,导入数据,删除旧表,修改
 | 
			
		||||
					if (ExecuteScalar(tbname[0], " SELECT 1 FROM information_schema.TABLES WHERE table_schema={0} and table_name={1}".FormatMySql(tbname)) == null) { //表不存在
 | 
			
		||||
					if (ExecuteScalar(tbname[0], _commonUtils.FormatSql(" SELECT 1 FROM information_schema.TABLES WHERE table_schema={0} and table_name={1}", tbname)) == null) { //表不存在
 | 
			
		||||
						if (tboldname != null) {
 | 
			
		||||
							if (string.Compare(tboldname[0], tbname[0], true) != 0 && ExecuteScalar(database, " select 1 from information_schema.schemata where schema_name={0}".FormatMySql(tboldname[0])) == null ||
 | 
			
		||||
								ExecuteScalar(tboldname[0], " SELECT 1 FROM information_schema.TABLES WHERE table_schema={0} and table_name={1}".FormatMySql(tboldname)) == null)
 | 
			
		||||
							if (string.Compare(tboldname[0], tbname[0], true) != 0 && ExecuteScalar(database, _commonUtils.FormatSql(" select 1 from information_schema.schemata where schema_name={0}", tboldname[0])) == null ||
 | 
			
		||||
								ExecuteScalar(tboldname[0], _commonUtils.FormatSql(" SELECT 1 FROM information_schema.TABLES WHERE table_schema={0} and table_name={1}", tboldname)) == null)
 | 
			
		||||
								//数据库或表不存在
 | 
			
		||||
								tboldname = null;
 | 
			
		||||
						}
 | 
			
		||||
@@ -159,14 +159,14 @@ namespace FreeSql.MySql {
 | 
			
		||||
						tboldname = null; //如果新表已经存在,不走改表名逻辑
 | 
			
		||||
 | 
			
		||||
					//对比字段,只可以修改类型、增加字段、有限的修改字段名;保证安全不删除字段
 | 
			
		||||
					var sql = @"
 | 
			
		||||
					var sql = _commonUtils.FormatSql(@"
 | 
			
		||||
select
 | 
			
		||||
a.column_name,
 | 
			
		||||
a.column_type,
 | 
			
		||||
case when a.is_nullable = 'YES' then 1 else 0 end 'is_nullable',
 | 
			
		||||
case when locate('auto_increment', a.extra) > 0 then 1 else 0 end 'is_identity'
 | 
			
		||||
from information_schema.columns a
 | 
			
		||||
where a.table_schema in ({0}) and a.table_name in ({1})".FormatMySql(tboldname ?? tbname);
 | 
			
		||||
where a.table_schema in ({0}) and a.table_name in ({1})", tboldname ?? tbname);
 | 
			
		||||
					var ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
 | 
			
		||||
					var tbstruct = ds.ToDictionary(a => string.Concat(a[0]), a => {
 | 
			
		||||
						var a1 = string.Concat(a[1]);
 | 
			
		||||
@@ -181,7 +181,7 @@ where a.table_schema in ({0}) and a.table_name in ({1})".FormatMySql(tboldname ?
 | 
			
		||||
					}, StringComparer.CurrentCultureIgnoreCase);
 | 
			
		||||
 | 
			
		||||
					if (istmpatler == false) {
 | 
			
		||||
						var existsPrimary = ExecuteScalar(tbname[0], "select 1 from information_schema.key_column_usage where table_schema={0} and table_name={1} and constraint_name = 'PRIMARY' limit 1".FormatMySql(tbname));
 | 
			
		||||
						var existsPrimary = ExecuteScalar(tbname[0], _commonUtils.FormatSql("select 1 from information_schema.key_column_usage where table_schema={0} and table_name={1} and constraint_name = 'PRIMARY' limit 1", tbname));
 | 
			
		||||
						foreach (var tbcol in tb.Columns.Values) {
 | 
			
		||||
							var isIdentityChanged = tbcol.Attribute.IsIdentity == true && tbcol.Attribute.DbType.IndexOf("AUTO_INCREMENT", StringComparison.CurrentCultureIgnoreCase) == -1;
 | 
			
		||||
							if (tbstruct.TryGetValue(tbcol.Attribute.Name, out var tbstructcol) ||
 | 
			
		||||
@@ -207,12 +207,12 @@ where a.table_schema in ({0}) and a.table_name in ({1})".FormatMySql(tboldname ?
 | 
			
		||||
							if (isIdentityChanged) sbalter.Append(" AUTO_INCREMENT").Append(existsPrimary == null ? "" : ", DROP PRIMARY KEY").Append(", ADD PRIMARY KEY(").Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(")");
 | 
			
		||||
							sbalter.Append(";\r\n");
 | 
			
		||||
						}
 | 
			
		||||
						var dsuksql = @"
 | 
			
		||||
						var dsuksql = _commonUtils.FormatSql(@"
 | 
			
		||||
select 
 | 
			
		||||
a.column_name,
 | 
			
		||||
a.constraint_name 'index_id'
 | 
			
		||||
from information_schema.key_column_usage a
 | 
			
		||||
where a.constraint_schema IN ({0}) and a.table_name IN ({1})".FormatMySql(tboldname ?? tbname);
 | 
			
		||||
where a.constraint_schema IN ({0}) and a.table_name IN ({1})", tboldname ?? tbname);
 | 
			
		||||
						var dsuk = _orm.Ado.ExecuteArray(CommandType.Text, dsuksql).Select(a => new[] { string.Concat(a[0]), string.Concat(a[1]) });
 | 
			
		||||
						foreach (var uk in tb.Uniques) {
 | 
			
		||||
							if (uk.Key == "PRIMARY" || string.IsNullOrEmpty(uk.Key) || uk.Value.Any() == false) continue;
 | 
			
		||||
 
 | 
			
		||||
@@ -149,7 +149,7 @@ namespace FreeSql.MySql {
 | 
			
		||||
					database = new[] { conn.Value.Database };
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			var databaseIn = string.Join(",", database.Select(a => "{0}".FormatMySql(a)));
 | 
			
		||||
			var databaseIn = string.Join(",", database.Select(a => _commonUtils.FormatSql("{0}", a)));
 | 
			
		||||
			var sql = string.Format(@"
 | 
			
		||||
select 
 | 
			
		||||
concat(a.table_schema, '.', a.table_name) 'id',
 | 
			
		||||
 
 | 
			
		||||
@@ -95,14 +95,14 @@ namespace FreeSql.Oracle {
 | 
			
		||||
				var tboldname = tb.DbOldName?.Split(new[] { '.' }, 2); //旧表名
 | 
			
		||||
				if (tboldname?.Length == 1) tboldname = new[] { userId, tboldname[0] };
 | 
			
		||||
 | 
			
		||||
				if (string.Compare(tbname[0], userId) != 0 && _orm.Ado.ExecuteScalar(CommandType.Text, " select 1 from sys.dba_users where username={0}".FormatOracleSQL(tbname[0])) == null) //创建数据库
 | 
			
		||||
				if (string.Compare(tbname[0], userId) != 0 && _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(" select 1 from sys.dba_users where username={0}", tbname[0])) == null) //创建数据库
 | 
			
		||||
					throw new NotImplementedException($"Oracle CodeFirst 不支持代码创建 tablespace 与 schemas {tbname[0]}");
 | 
			
		||||
 | 
			
		||||
				var sbalter = new StringBuilder();
 | 
			
		||||
				var istmpatler = false; //创建临时表,导入数据,删除旧表,修改
 | 
			
		||||
				if (_orm.Ado.ExecuteScalar(CommandType.Text, " select 1 from all_tab_comments where owner={0} and table_name={1}".FormatOracleSQL(tbname)) == null) { //表不存在
 | 
			
		||||
				if (_orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(" select 1 from all_tab_comments where owner={0} and table_name={1}", tbname)) == null) { //表不存在
 | 
			
		||||
					if (tboldname != null) {
 | 
			
		||||
						if (_orm.Ado.ExecuteScalar(CommandType.Text, " select 1 from all_tab_comments where owner={0} and table_name={1}".FormatOracleSQL(tboldname)) == null)
 | 
			
		||||
						if (_orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(" select 1 from all_tab_comments where owner={0} and table_name={1}", tboldname)) == null)
 | 
			
		||||
							//模式或表不存在
 | 
			
		||||
							tboldname = null;
 | 
			
		||||
					}
 | 
			
		||||
@@ -138,7 +138,7 @@ namespace FreeSql.Oracle {
 | 
			
		||||
					tboldname = null; //如果新表已经存在,不走改表名逻辑
 | 
			
		||||
 | 
			
		||||
				//对比字段,只可以修改类型、增加字段、有限的修改字段名;保证安全不删除字段
 | 
			
		||||
				var sql = $@"
 | 
			
		||||
				var sql = _commonUtils.FormatSql($@"
 | 
			
		||||
select 
 | 
			
		||||
column_name,
 | 
			
		||||
data_type,
 | 
			
		||||
@@ -150,7 +150,7 @@ case when nullable = 'Y' then 1 else 0 end,
 | 
			
		||||
nvl((select 1 from user_sequences where sequence_name='{Utils.GetCsName((tboldname ?? tbname).Last())}_seq_'||all_tab_columns.column_name), 0),
 | 
			
		||||
nvl((select 1 from user_triggers where trigger_name='{Utils.GetCsName((tboldname ?? tbname).Last())}_seq_'||all_tab_columns.column_name||'TI'), 0)
 | 
			
		||||
from all_tab_columns
 | 
			
		||||
where owner={{0}} and table_name={{1}}".FormatOracleSQL(tboldname ?? tbname);
 | 
			
		||||
where owner={{0}} and table_name={{1}}", tboldname ?? tbname);
 | 
			
		||||
				var ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
 | 
			
		||||
				var tbstruct = ds.ToDictionary(a => string.Concat(a[0]), a => {
 | 
			
		||||
					var sqlType = GetOracleSqlTypeFullName(a);
 | 
			
		||||
@@ -190,7 +190,7 @@ where owner={{0}} and table_name={{1}}".FormatOracleSQL(tboldname ?? tbname);
 | 
			
		||||
						}
 | 
			
		||||
						if (tbcol.Attribute.IsIdentity == true) seqcols.Add((tbcol, tbname, tbcol.Attribute.IsIdentity == true));
 | 
			
		||||
					}
 | 
			
		||||
					var dsuksql = @"
 | 
			
		||||
					var dsuksql = _commonUtils.FormatSql(@"
 | 
			
		||||
select
 | 
			
		||||
c.column_name,
 | 
			
		||||
c.constraint_name
 | 
			
		||||
@@ -202,7 +202,7 @@ a.constraint_name = c.constraint_name
 | 
			
		||||
and a.owner = c.owner
 | 
			
		||||
and a.table_name = c.table_name
 | 
			
		||||
and a.constraint_type in ('U')
 | 
			
		||||
and a.owner in ({0}) and a.table_name in ({1})".FormatMySql(tboldname ?? tbname);
 | 
			
		||||
and a.owner in ({0}) and a.table_name in ({1})", tboldname ?? tbname);
 | 
			
		||||
					var dsuk = _orm.Ado.ExecuteArray(CommandType.Text, dsuksql).Select(a => new[] { string.Concat(a[0]), string.Concat(a[1]) });
 | 
			
		||||
					foreach (var uk in tb.Uniques) {
 | 
			
		||||
						if (string.IsNullOrEmpty(uk.Key) || uk.Value.Any() == false) continue;
 | 
			
		||||
@@ -219,7 +219,7 @@ and a.owner in ({0}) and a.table_name in ({1})".FormatMySql(tboldname ?? tbname)
 | 
			
		||||
					sb.Append(sbalter);
 | 
			
		||||
					continue;
 | 
			
		||||
				}
 | 
			
		||||
				var oldpk = _orm.Ado.ExecuteScalar(CommandType.Text, @"select constraint_name from user_constraints where owner={0} and table_name={1} and constraint_type='P'".FormatPostgreSQL(tbname))?.ToString();
 | 
			
		||||
				var oldpk = _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(@"select constraint_name from user_constraints where owner={0} and table_name={1} and constraint_type='P'", tbname))?.ToString();
 | 
			
		||||
				if (string.IsNullOrEmpty(oldpk) == false)
 | 
			
		||||
					sb.Append("execute immediate 'ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" DROP CONSTRAINT ").Append(oldpk).Append("';\r\n");
 | 
			
		||||
 | 
			
		||||
@@ -279,12 +279,12 @@ and a.owner in ({0}) and a.table_name in ({1})".FormatMySql(tboldname ?? tbname)
 | 
			
		||||
					dicDeclare.Add(seqname, true);
 | 
			
		||||
				}
 | 
			
		||||
				sb.Append(seqname).Append("IS := 0; \r\n")
 | 
			
		||||
					.Append(" select count(1) into ").Append(seqname).Append("IS from user_sequences where sequence_name={0}; \r\n".FormatOracleSQL(seqname))
 | 
			
		||||
					.Append(" select count(1) into ").Append(seqname).Append(_commonUtils.FormatSql("IS from user_sequences where sequence_name={0}; \r\n", seqname))
 | 
			
		||||
					.Append("if ").Append(seqname).Append("IS > 0 then \r\n")
 | 
			
		||||
					.Append("  execute immediate 'DROP SEQUENCE ").Append(_commonUtils.QuoteSqlName(seqname)).Append("';\r\n")
 | 
			
		||||
					.Append("end if; \r\n");
 | 
			
		||||
				if (seqcol.Item3) {
 | 
			
		||||
					var startWith = _orm.Ado.ExecuteScalar(CommandType.Text, " select 1 from all_tab_comments where owner={0} and table_name={1}".FormatOracleSQL(tbname)) == null ? 1 :
 | 
			
		||||
					var startWith = _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(" select 1 from all_tab_comments where owner={0} and table_name={1}", tbname)) == null ? 1 :
 | 
			
		||||
						_orm.Ado.ExecuteScalar(CommandType.Text, $" select nvl(max({colname2})+1,1) from {tbname2}");
 | 
			
		||||
					sb.Append("execute immediate 'CREATE SEQUENCE ").Append(_commonUtils.QuoteSqlName(seqname)).Append(" start with ").Append(startWith).Append("';\r\n");
 | 
			
		||||
					sb.Append("execute immediate 'CREATE OR REPLACE TRIGGER ").Append(_commonUtils.QuoteSqlName(tiggerName))
 | 
			
		||||
@@ -297,7 +297,7 @@ and a.owner in ({0}) and a.table_name in ({1})".FormatMySql(tboldname ?? tbname)
 | 
			
		||||
						dicDeclare.Add(tiggerName, true);
 | 
			
		||||
					}
 | 
			
		||||
					sb.Append(tiggerName).Append("IS := 0; \r\n")
 | 
			
		||||
					.Append(" select count(1) into ").Append(tiggerName).Append("IS from user_triggers where trigger_name={0}; \r\n".FormatOracleSQL(tiggerName))
 | 
			
		||||
					.Append(" select count(1) into ").Append(tiggerName).Append(_commonUtils.FormatSql("IS from user_triggers where trigger_name={0}; \r\n", tiggerName))
 | 
			
		||||
					.Append("if ").Append(tiggerName).Append("IS > 0 then \r\n")
 | 
			
		||||
					.Append("  execute immediate 'DROP TRIGGER ").Append(_commonUtils.QuoteSqlName(tiggerName)).Append("';\r\n")
 | 
			
		||||
					.Append("end if; \r\n");
 | 
			
		||||
 
 | 
			
		||||
@@ -145,7 +145,7 @@ namespace FreeSql.Oracle {
 | 
			
		||||
				if (string.IsNullOrEmpty(userUsers)) return loc1;
 | 
			
		||||
				database = new[] { userUsers };
 | 
			
		||||
			}
 | 
			
		||||
			var databaseIn = string.Join(",", database.Select(a => "{0}".FormatOracleSQL(a)));
 | 
			
		||||
			var databaseIn = string.Join(",", database.Select(a => _commonUtils.FormatSql("{0}", a)));
 | 
			
		||||
			var sql = string.Format(@"
 | 
			
		||||
select
 | 
			
		||||
a.owner || '.' || a.table_name,
 | 
			
		||||
 
 | 
			
		||||
@@ -138,7 +138,7 @@ namespace FreeSql.PostgreSQL {
 | 
			
		||||
				var tboldname = tb.DbOldName?.Split(new[] { '.' }, 2); //旧表名
 | 
			
		||||
				if (tboldname?.Length == 1) tboldname = new[] { "public", tboldname[0] };
 | 
			
		||||
 | 
			
		||||
				if (string.Compare(tbname[0], "public", true) != 0 && _orm.Ado.ExecuteScalar(CommandType.Text, " select 1 from pg_namespace where nspname={0}".FormatPostgreSQL(tbname[0])) == null) //创建模式
 | 
			
		||||
				if (string.Compare(tbname[0], "public", true) != 0 && _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(" select 1 from pg_namespace where nspname={0}", tbname[0])) == null) //创建模式
 | 
			
		||||
					sb.Append("CREATE SCHEMA IF NOT EXISTS ").Append(tbname[0]).Append(";\r\n");
 | 
			
		||||
 | 
			
		||||
				var sbalter = new StringBuilder();
 | 
			
		||||
@@ -181,7 +181,7 @@ namespace FreeSql.PostgreSQL {
 | 
			
		||||
					tboldname = null; //如果新表已经存在,不走改表名逻辑
 | 
			
		||||
 | 
			
		||||
				//对比字段,只可以修改类型、增加字段、有限的修改字段名;保证安全不删除字段
 | 
			
		||||
				var sql = @"
 | 
			
		||||
				var sql = _commonUtils.FormatSql(@"
 | 
			
		||||
select
 | 
			
		||||
a.attname,
 | 
			
		||||
t.typname,
 | 
			
		||||
@@ -198,7 +198,7 @@ left join pg_description d on d.objoid = a.attrelid and d.objsubid = a.attnum
 | 
			
		||||
left join pg_attrdef e on e.adrelid = a.attrelid and e.adnum = a.attnum
 | 
			
		||||
inner join pg_namespace ns on ns.oid = c.relnamespace
 | 
			
		||||
inner join pg_namespace ns2 on ns2.oid = t.typnamespace
 | 
			
		||||
where ns.nspname = {0} and c.relname = {1}".FormatPostgreSQL(tboldname ?? tbname);
 | 
			
		||||
where ns.nspname = {0} and c.relname = {1}", tboldname ?? tbname);
 | 
			
		||||
				var ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
 | 
			
		||||
				var tbstruct = ds.ToDictionary(a => string.Concat(a[0]), a => {
 | 
			
		||||
					var attndims = int.Parse(string.Concat(a[6]));
 | 
			
		||||
@@ -246,7 +246,7 @@ where ns.nspname = {0} and c.relname = {1}".FormatPostgreSQL(tboldname ?? tbname
 | 
			
		||||
						if (tbcol.Attribute.IsNullable == false) sbalter.Append("ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" ALTER COLUMN ").Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(" SET NOT NULL;\r\n");
 | 
			
		||||
						if (tbcol.Attribute.IsIdentity == true) seqcols.Add((tbcol, tbname, tbcol.Attribute.IsIdentity == true));
 | 
			
		||||
					}
 | 
			
		||||
					var dsuksql = @"
 | 
			
		||||
					var dsuksql = _commonUtils.FormatSql(@"
 | 
			
		||||
select
 | 
			
		||||
c.attname,
 | 
			
		||||
b.relname
 | 
			
		||||
@@ -255,7 +255,7 @@ inner join pg_class b on b.oid = a.indexrelid
 | 
			
		||||
inner join pg_attribute c on c.attnum > 0 and c.attrelid = b.oid
 | 
			
		||||
inner join pg_namespace ns on ns.oid = b.relnamespace
 | 
			
		||||
inner join pg_class d on d.oid = a.indrelid
 | 
			
		||||
where ns.nspname in ({0}) and d.relname in ({1}) and a.indisunique = 't'".FormatMySql(tboldname ?? tbname);
 | 
			
		||||
where ns.nspname in ({0}) and d.relname in ({1}) and a.indisunique = 't'", tboldname ?? tbname);
 | 
			
		||||
					var dsuk = _orm.Ado.ExecuteArray(CommandType.Text, dsuksql).Select(a => new[] { string.Concat(a[0]), string.Concat(a[1]) });
 | 
			
		||||
					foreach (var uk in tb.Uniques) {
 | 
			
		||||
						if (string.IsNullOrEmpty(uk.Key) || uk.Value.Any() == false) continue;
 | 
			
		||||
@@ -272,11 +272,11 @@ where ns.nspname in ({0}) and d.relname in ({1}) and a.indisunique = 't'".Format
 | 
			
		||||
					sb.Append(sbalter);
 | 
			
		||||
					continue;
 | 
			
		||||
				}
 | 
			
		||||
				var oldpk = _orm.Ado.ExecuteScalar(CommandType.Text, @"select pg_constraint.conname as pk_name from pg_constraint
 | 
			
		||||
				var oldpk = _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(@"select pg_constraint.conname as pk_name from pg_constraint
 | 
			
		||||
inner join pg_class on pg_constraint.conrelid = pg_class.oid
 | 
			
		||||
inner join pg_namespace on pg_namespace.oid = pg_class.relnamespace
 | 
			
		||||
where pg_namespace.nspname={0} and pg_class.relname={1} and pg_constraint.contype='p'
 | 
			
		||||
".FormatPostgreSQL(tbname))?.ToString();
 | 
			
		||||
", tbname))?.ToString();
 | 
			
		||||
				if (string.IsNullOrEmpty(oldpk) == false)
 | 
			
		||||
					sb.Append("ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" DROP CONSTRAINT ").Append(oldpk).Append(";\r\n");
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -501,14 +501,14 @@ where ns.nspname || '.' || b.relname in ({loc8})
 | 
			
		||||
 | 
			
		||||
		public List<DbEnumInfo> GetEnumsByDatabase(params string[] database) {
 | 
			
		||||
			if (database == null || database.Length == 0) return new List<DbEnumInfo>();
 | 
			
		||||
			var drs = _orm.Ado.Query<(string name, string label)>(CommandType.Text, @"
 | 
			
		||||
			var drs = _orm.Ado.Query<(string name, string label)>(CommandType.Text, _commonUtils.FormatSql(@"
 | 
			
		||||
select
 | 
			
		||||
ns.nspname || '.' || a.typname,
 | 
			
		||||
b.enumlabel
 | 
			
		||||
from pg_type a
 | 
			
		||||
inner join pg_enum b on b.enumtypid = a.oid
 | 
			
		||||
inner join pg_namespace ns on ns.oid = a.typnamespace
 | 
			
		||||
where a.typtype = 'e' and ns.nspname in (SELECT ""schema_name"" FROM information_schema.schemata where catalog_name in {0})".FormatPostgreSQL(database));
 | 
			
		||||
where a.typtype = 'e' and ns.nspname in (SELECT ""schema_name"" FROM information_schema.schemata where catalog_name in {0})", database));
 | 
			
		||||
			var ret = new Dictionary<string, Dictionary<string, string>>();
 | 
			
		||||
			foreach (var dr in drs) {
 | 
			
		||||
				if (ret.TryGetValue(dr.name, out var labels) == false) ret.Add(dr.name, labels = new Dictionary<string, string>());
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user