mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 17:20:49 +08:00 
			
		
		
		
	- fix: CustomAdapter
This commit is contained in:
		@@ -40,7 +40,7 @@ namespace FreeSql.Custom
 | 
				
			|||||||
            });
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        static FreeSql.Custom.CustomAdo _customAdo = new FreeSql.Custom.CustomAdo();
 | 
					        static FreeSql.Custom.CustomAdo _customAdo = new FreeSql.Custom.CustomAdo();
 | 
				
			||||||
        public override string FormatSql(string sql, params object[] args) => _customAdo.Addslashes(sql, args);
 | 
					        public override string FormatSql(string sql, params object[] args) => (_orm?.Ado as CustomAdo)?.Addslashes(sql, args) ?? _customAdo.Addslashes(sql, args);
 | 
				
			||||||
        public override string QuoteSqlName(params string[] name)
 | 
					        public override string QuoteSqlName(params string[] name)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (name.Length == 1)
 | 
					            if (name.Length == 1)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -172,8 +172,8 @@ namespace FreeSql.MySql
 | 
				
			|||||||
        public List<DbTableInfo> GetTables(string[] database, string tablename, bool ignoreCase)
 | 
					        public List<DbTableInfo> GetTables(string[] database, string tablename, bool ignoreCase)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var loc1 = new List<DbTableInfo>();
 | 
					            var loc1 = new List<DbTableInfo>();
 | 
				
			||||||
            var loc2 = new Dictionary<string, DbTableInfo>();
 | 
					            var loc2 = new Dictionary<string, DbTableInfo>(StringComparer.CurrentCultureIgnoreCase);
 | 
				
			||||||
            var loc3 = new Dictionary<string, Dictionary<string, DbColumnInfo>>();
 | 
					            var loc3 = new Dictionary<string, Dictionary<string, DbColumnInfo>>(StringComparer.CurrentCultureIgnoreCase);
 | 
				
			||||||
            string[] tbname = null;
 | 
					            string[] tbname = null;
 | 
				
			||||||
            if (string.IsNullOrEmpty(tablename) == false)
 | 
					            if (string.IsNullOrEmpty(tablename) == false)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
@@ -228,7 +228,7 @@ where {(ignoreCase ? "lower(a.table_schema)" : "a.table_schema")} in ({databaseI
 | 
				
			|||||||
                    schema = "";
 | 
					                    schema = "";
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                loc2.Add(table_id, new DbTableInfo { Id = table_id, Schema = schema, Name = table, Comment = comment, Type = type });
 | 
					                loc2.Add(table_id, new DbTableInfo { Id = table_id, Schema = schema, Name = table, Comment = comment, Type = type });
 | 
				
			||||||
                loc3.Add(table_id, new Dictionary<string, DbColumnInfo>());
 | 
					                loc3.Add(table_id, new Dictionary<string, DbColumnInfo>(StringComparer.CurrentCultureIgnoreCase));
 | 
				
			||||||
                switch (type)
 | 
					                switch (type)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    case DbTableType.TABLE:
 | 
					                    case DbTableType.TABLE:
 | 
				
			||||||
@@ -337,8 +337,8 @@ where {(ignoreCase ? "lower(a.table_schema)" : "a.table_schema")} in ({databaseI
 | 
				
			|||||||
            ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
 | 
					            ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
 | 
				
			||||||
            if (ds == null) return loc1;
 | 
					            if (ds == null) return loc1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var indexColumns = new Dictionary<string, Dictionary<string, DbIndexInfo>>();
 | 
					            var indexColumns = new Dictionary<string, Dictionary<string, DbIndexInfo>>(StringComparer.CurrentCultureIgnoreCase);
 | 
				
			||||||
            var uniqueColumns = new Dictionary<string, Dictionary<string, DbIndexInfo>>();
 | 
					            var uniqueColumns = new Dictionary<string, Dictionary<string, DbIndexInfo>>(StringComparer.CurrentCultureIgnoreCase);
 | 
				
			||||||
            foreach (var row in ds)
 | 
					            foreach (var row in ds)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                string table_id = string.Concat(row[0]);
 | 
					                string table_id = string.Concat(row[0]);
 | 
				
			||||||
@@ -357,14 +357,14 @@ where {(ignoreCase ? "lower(a.table_schema)" : "a.table_schema")} in ({databaseI
 | 
				
			|||||||
                Dictionary<string, DbIndexInfo> loc10 = null;
 | 
					                Dictionary<string, DbIndexInfo> loc10 = null;
 | 
				
			||||||
                DbIndexInfo loc11 = null;
 | 
					                DbIndexInfo loc11 = null;
 | 
				
			||||||
                if (!indexColumns.TryGetValue(table_id, out loc10))
 | 
					                if (!indexColumns.TryGetValue(table_id, out loc10))
 | 
				
			||||||
                    indexColumns.Add(table_id, loc10 = new Dictionary<string, DbIndexInfo>());
 | 
					                    indexColumns.Add(table_id, loc10 = new Dictionary<string, DbIndexInfo>(StringComparer.CurrentCultureIgnoreCase));
 | 
				
			||||||
                if (!loc10.TryGetValue(index_id, out loc11))
 | 
					                if (!loc10.TryGetValue(index_id, out loc11))
 | 
				
			||||||
                    loc10.Add(index_id, loc11 = new DbIndexInfo());
 | 
					                    loc10.Add(index_id, loc11 = new DbIndexInfo());
 | 
				
			||||||
                loc11.Columns.Add(new DbIndexColumnInfo { Column = loc9, IsDesc = is_desc });
 | 
					                loc11.Columns.Add(new DbIndexColumnInfo { Column = loc9, IsDesc = is_desc });
 | 
				
			||||||
                if (is_unique && !is_primary_key)
 | 
					                if (is_unique && !is_primary_key)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    if (!uniqueColumns.TryGetValue(table_id, out loc10))
 | 
					                    if (!uniqueColumns.TryGetValue(table_id, out loc10))
 | 
				
			||||||
                        uniqueColumns.Add(table_id, loc10 = new Dictionary<string, DbIndexInfo>());
 | 
					                        uniqueColumns.Add(table_id, loc10 = new Dictionary<string, DbIndexInfo>(StringComparer.CurrentCultureIgnoreCase));
 | 
				
			||||||
                    if (!loc10.TryGetValue(index_id, out loc11))
 | 
					                    if (!loc10.TryGetValue(index_id, out loc11))
 | 
				
			||||||
                        loc10.Add(index_id, loc11 = new DbIndexInfo());
 | 
					                        loc10.Add(index_id, loc11 = new DbIndexInfo());
 | 
				
			||||||
                    loc11.Columns.Add(new DbIndexColumnInfo { Column = loc9, IsDesc = is_desc });
 | 
					                    loc11.Columns.Add(new DbIndexColumnInfo { Column = loc9, IsDesc = is_desc });
 | 
				
			||||||
@@ -400,7 +400,7 @@ where {(ignoreCase ? "lower(a.constraint_schema)" : "a.constraint_schema")} in (
 | 
				
			|||||||
                ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
 | 
					                ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
 | 
				
			||||||
                if (ds == null) return loc1;
 | 
					                if (ds == null) return loc1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                var fkColumns = new Dictionary<string, Dictionary<string, DbForeignInfo>>();
 | 
					                var fkColumns = new Dictionary<string, Dictionary<string, DbForeignInfo>>(StringComparer.CurrentCultureIgnoreCase);
 | 
				
			||||||
                foreach (var row in ds)
 | 
					                foreach (var row in ds)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    string table_id = string.Concat(row[0]);
 | 
					                    string table_id = string.Concat(row[0]);
 | 
				
			||||||
@@ -423,7 +423,7 @@ where {(ignoreCase ? "lower(a.constraint_schema)" : "a.constraint_schema")} in (
 | 
				
			|||||||
                    Dictionary<string, DbForeignInfo> loc12 = null;
 | 
					                    Dictionary<string, DbForeignInfo> loc12 = null;
 | 
				
			||||||
                    DbForeignInfo loc13 = null;
 | 
					                    DbForeignInfo loc13 = null;
 | 
				
			||||||
                    if (!fkColumns.TryGetValue(table_id, out loc12))
 | 
					                    if (!fkColumns.TryGetValue(table_id, out loc12))
 | 
				
			||||||
                        fkColumns.Add(table_id, loc12 = new Dictionary<string, DbForeignInfo>());
 | 
					                        fkColumns.Add(table_id, loc12 = new Dictionary<string, DbForeignInfo>(StringComparer.CurrentCultureIgnoreCase));
 | 
				
			||||||
                    if (!loc12.TryGetValue(fk_id, out loc13))
 | 
					                    if (!loc12.TryGetValue(fk_id, out loc13))
 | 
				
			||||||
                        loc12.Add(fk_id, loc13 = new DbForeignInfo { Table = loc2[table_id], ReferencedTable = loc10 });
 | 
					                        loc12.Add(fk_id, loc13 = new DbForeignInfo { Table = loc2[table_id], ReferencedTable = loc10 });
 | 
				
			||||||
                    loc13.Columns.Add(loc9);
 | 
					                    loc13.Columns.Add(loc9);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -138,8 +138,8 @@ namespace FreeSql.Odbc.MySql
 | 
				
			|||||||
        public List<DbTableInfo> GetTables(string[] database, string tablename, bool ignoreCase)
 | 
					        public List<DbTableInfo> GetTables(string[] database, string tablename, bool ignoreCase)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var loc1 = new List<DbTableInfo>();
 | 
					            var loc1 = new List<DbTableInfo>();
 | 
				
			||||||
            var loc2 = new Dictionary<string, DbTableInfo>();
 | 
					            var loc2 = new Dictionary<string, DbTableInfo>(StringComparer.CurrentCultureIgnoreCase);
 | 
				
			||||||
            var loc3 = new Dictionary<string, Dictionary<string, DbColumnInfo>>();
 | 
					            var loc3 = new Dictionary<string, Dictionary<string, DbColumnInfo>>(StringComparer.CurrentCultureIgnoreCase);
 | 
				
			||||||
            string[] tbname = null;
 | 
					            string[] tbname = null;
 | 
				
			||||||
            if (string.IsNullOrEmpty(tablename) == false)
 | 
					            if (string.IsNullOrEmpty(tablename) == false)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
@@ -194,7 +194,7 @@ where {(ignoreCase ? "lower(a.table_schema)" : "a.table_schema")} in ({databaseI
 | 
				
			|||||||
                    schema = "";
 | 
					                    schema = "";
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                loc2.Add(table_id, new DbTableInfo { Id = table_id, Schema = schema, Name = table, Comment = comment, Type = type });
 | 
					                loc2.Add(table_id, new DbTableInfo { Id = table_id, Schema = schema, Name = table, Comment = comment, Type = type });
 | 
				
			||||||
                loc3.Add(table_id, new Dictionary<string, DbColumnInfo>());
 | 
					                loc3.Add(table_id, new Dictionary<string, DbColumnInfo>(StringComparer.CurrentCultureIgnoreCase));
 | 
				
			||||||
                switch (type)
 | 
					                switch (type)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    case DbTableType.TABLE:
 | 
					                    case DbTableType.TABLE:
 | 
				
			||||||
@@ -303,8 +303,8 @@ where {(ignoreCase ? "lower(a.table_schema)" : "a.table_schema")} in ({databaseI
 | 
				
			|||||||
            ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
 | 
					            ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
 | 
				
			||||||
            if (ds == null) return loc1;
 | 
					            if (ds == null) return loc1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var indexColumns = new Dictionary<string, Dictionary<string, DbIndexInfo>>();
 | 
					            var indexColumns = new Dictionary<string, Dictionary<string, DbIndexInfo>>(StringComparer.CurrentCultureIgnoreCase);
 | 
				
			||||||
            var uniqueColumns = new Dictionary<string, Dictionary<string, DbIndexInfo>>();
 | 
					            var uniqueColumns = new Dictionary<string, Dictionary<string, DbIndexInfo>>(StringComparer.CurrentCultureIgnoreCase);
 | 
				
			||||||
            foreach (var row in ds)
 | 
					            foreach (var row in ds)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                string table_id = string.Concat(row[0]);
 | 
					                string table_id = string.Concat(row[0]);
 | 
				
			||||||
@@ -323,14 +323,14 @@ where {(ignoreCase ? "lower(a.table_schema)" : "a.table_schema")} in ({databaseI
 | 
				
			|||||||
                Dictionary<string, DbIndexInfo> loc10 = null;
 | 
					                Dictionary<string, DbIndexInfo> loc10 = null;
 | 
				
			||||||
                DbIndexInfo loc11 = null;
 | 
					                DbIndexInfo loc11 = null;
 | 
				
			||||||
                if (!indexColumns.TryGetValue(table_id, out loc10))
 | 
					                if (!indexColumns.TryGetValue(table_id, out loc10))
 | 
				
			||||||
                    indexColumns.Add(table_id, loc10 = new Dictionary<string, DbIndexInfo>());
 | 
					                    indexColumns.Add(table_id, loc10 = new Dictionary<string, DbIndexInfo>(StringComparer.CurrentCultureIgnoreCase));
 | 
				
			||||||
                if (!loc10.TryGetValue(index_id, out loc11))
 | 
					                if (!loc10.TryGetValue(index_id, out loc11))
 | 
				
			||||||
                    loc10.Add(index_id, loc11 = new DbIndexInfo());
 | 
					                    loc10.Add(index_id, loc11 = new DbIndexInfo());
 | 
				
			||||||
                loc11.Columns.Add(new DbIndexColumnInfo { Column = loc9, IsDesc = is_desc });
 | 
					                loc11.Columns.Add(new DbIndexColumnInfo { Column = loc9, IsDesc = is_desc });
 | 
				
			||||||
                if (is_unique && !is_primary_key)
 | 
					                if (is_unique && !is_primary_key)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    if (!uniqueColumns.TryGetValue(table_id, out loc10))
 | 
					                    if (!uniqueColumns.TryGetValue(table_id, out loc10))
 | 
				
			||||||
                        uniqueColumns.Add(table_id, loc10 = new Dictionary<string, DbIndexInfo>());
 | 
					                        uniqueColumns.Add(table_id, loc10 = new Dictionary<string, DbIndexInfo>(StringComparer.CurrentCultureIgnoreCase));
 | 
				
			||||||
                    if (!loc10.TryGetValue(index_id, out loc11))
 | 
					                    if (!loc10.TryGetValue(index_id, out loc11))
 | 
				
			||||||
                        loc10.Add(index_id, loc11 = new DbIndexInfo());
 | 
					                        loc10.Add(index_id, loc11 = new DbIndexInfo());
 | 
				
			||||||
                    loc11.Columns.Add(new DbIndexColumnInfo { Column = loc9, IsDesc = is_desc });
 | 
					                    loc11.Columns.Add(new DbIndexColumnInfo { Column = loc9, IsDesc = is_desc });
 | 
				
			||||||
@@ -366,7 +366,7 @@ where {(ignoreCase ? "lower(a.constraint_schema)" : "a.constraint_schema")} in (
 | 
				
			|||||||
                ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
 | 
					                ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
 | 
				
			||||||
                if (ds == null) return loc1;
 | 
					                if (ds == null) return loc1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                var fkColumns = new Dictionary<string, Dictionary<string, DbForeignInfo>>();
 | 
					                var fkColumns = new Dictionary<string, Dictionary<string, DbForeignInfo>>(StringComparer.CurrentCultureIgnoreCase);
 | 
				
			||||||
                foreach (var row in ds)
 | 
					                foreach (var row in ds)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    string table_id = string.Concat(row[0]);
 | 
					                    string table_id = string.Concat(row[0]);
 | 
				
			||||||
@@ -389,7 +389,7 @@ where {(ignoreCase ? "lower(a.constraint_schema)" : "a.constraint_schema")} in (
 | 
				
			|||||||
                    Dictionary<string, DbForeignInfo> loc12 = null;
 | 
					                    Dictionary<string, DbForeignInfo> loc12 = null;
 | 
				
			||||||
                    DbForeignInfo loc13 = null;
 | 
					                    DbForeignInfo loc13 = null;
 | 
				
			||||||
                    if (!fkColumns.TryGetValue(table_id, out loc12))
 | 
					                    if (!fkColumns.TryGetValue(table_id, out loc12))
 | 
				
			||||||
                        fkColumns.Add(table_id, loc12 = new Dictionary<string, DbForeignInfo>());
 | 
					                        fkColumns.Add(table_id, loc12 = new Dictionary<string, DbForeignInfo>(StringComparer.CurrentCultureIgnoreCase));
 | 
				
			||||||
                    if (!loc12.TryGetValue(fk_id, out loc13))
 | 
					                    if (!loc12.TryGetValue(fk_id, out loc13))
 | 
				
			||||||
                        loc12.Add(fk_id, loc13 = new DbForeignInfo { Table = loc2[table_id], ReferencedTable = loc10 });
 | 
					                        loc12.Add(fk_id, loc13 = new DbForeignInfo { Table = loc2[table_id], ReferencedTable = loc10 });
 | 
				
			||||||
                    loc13.Columns.Add(loc9);
 | 
					                    loc13.Columns.Add(loc9);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user