From 30b20c39f990f7a3725170984b49587d2926fd95 Mon Sep 17 00:00:00 2001 From: 2881099 <2881099@qq.com> Date: Wed, 3 Nov 2021 16:20:02 +0800 Subject: [PATCH] - fix: CustomAdapter --- .../FreeSql.Provider.Custom/CustomUtils.cs | 2 +- .../FreeSql.Provider.MySql/MySqlDbFirst.cs | 18 +++++++++--------- .../MySql/OdbcMySqlDbFirst.cs | 18 +++++++++--------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Providers/FreeSql.Provider.Custom/CustomUtils.cs b/Providers/FreeSql.Provider.Custom/CustomUtils.cs index ebea701f..c3a99a4c 100644 --- a/Providers/FreeSql.Provider.Custom/CustomUtils.cs +++ b/Providers/FreeSql.Provider.Custom/CustomUtils.cs @@ -40,7 +40,7 @@ namespace FreeSql.Custom }); 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) { if (name.Length == 1) diff --git a/Providers/FreeSql.Provider.MySql/MySqlDbFirst.cs b/Providers/FreeSql.Provider.MySql/MySqlDbFirst.cs index 5ec430ec..2591ac38 100644 --- a/Providers/FreeSql.Provider.MySql/MySqlDbFirst.cs +++ b/Providers/FreeSql.Provider.MySql/MySqlDbFirst.cs @@ -172,8 +172,8 @@ namespace FreeSql.MySql public List GetTables(string[] database, string tablename, bool ignoreCase) { var loc1 = new List(); - var loc2 = new Dictionary(); - var loc3 = new Dictionary>(); + var loc2 = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + var loc3 = new Dictionary>(StringComparer.CurrentCultureIgnoreCase); string[] tbname = null; if (string.IsNullOrEmpty(tablename) == false) { @@ -228,7 +228,7 @@ where {(ignoreCase ? "lower(a.table_schema)" : "a.table_schema")} in ({databaseI schema = ""; } loc2.Add(table_id, new DbTableInfo { Id = table_id, Schema = schema, Name = table, Comment = comment, Type = type }); - loc3.Add(table_id, new Dictionary()); + loc3.Add(table_id, new Dictionary(StringComparer.CurrentCultureIgnoreCase)); switch (type) { 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); if (ds == null) return loc1; - var indexColumns = new Dictionary>(); - var uniqueColumns = new Dictionary>(); + var indexColumns = new Dictionary>(StringComparer.CurrentCultureIgnoreCase); + var uniqueColumns = new Dictionary>(StringComparer.CurrentCultureIgnoreCase); foreach (var row in ds) { string table_id = string.Concat(row[0]); @@ -357,14 +357,14 @@ where {(ignoreCase ? "lower(a.table_schema)" : "a.table_schema")} in ({databaseI Dictionary loc10 = null; DbIndexInfo loc11 = null; if (!indexColumns.TryGetValue(table_id, out loc10)) - indexColumns.Add(table_id, loc10 = new Dictionary()); + indexColumns.Add(table_id, loc10 = new Dictionary(StringComparer.CurrentCultureIgnoreCase)); if (!loc10.TryGetValue(index_id, out loc11)) loc10.Add(index_id, loc11 = new DbIndexInfo()); loc11.Columns.Add(new DbIndexColumnInfo { Column = loc9, IsDesc = is_desc }); if (is_unique && !is_primary_key) { if (!uniqueColumns.TryGetValue(table_id, out loc10)) - uniqueColumns.Add(table_id, loc10 = new Dictionary()); + uniqueColumns.Add(table_id, loc10 = new Dictionary(StringComparer.CurrentCultureIgnoreCase)); if (!loc10.TryGetValue(index_id, out loc11)) loc10.Add(index_id, loc11 = new DbIndexInfo()); 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); if (ds == null) return loc1; - var fkColumns = new Dictionary>(); + var fkColumns = new Dictionary>(StringComparer.CurrentCultureIgnoreCase); foreach (var row in ds) { string table_id = string.Concat(row[0]); @@ -423,7 +423,7 @@ where {(ignoreCase ? "lower(a.constraint_schema)" : "a.constraint_schema")} in ( Dictionary loc12 = null; DbForeignInfo loc13 = null; if (!fkColumns.TryGetValue(table_id, out loc12)) - fkColumns.Add(table_id, loc12 = new Dictionary()); + fkColumns.Add(table_id, loc12 = new Dictionary(StringComparer.CurrentCultureIgnoreCase)); if (!loc12.TryGetValue(fk_id, out loc13)) loc12.Add(fk_id, loc13 = new DbForeignInfo { Table = loc2[table_id], ReferencedTable = loc10 }); loc13.Columns.Add(loc9); diff --git a/Providers/FreeSql.Provider.Odbc/MySql/OdbcMySqlDbFirst.cs b/Providers/FreeSql.Provider.Odbc/MySql/OdbcMySqlDbFirst.cs index b655037c..e3996d91 100644 --- a/Providers/FreeSql.Provider.Odbc/MySql/OdbcMySqlDbFirst.cs +++ b/Providers/FreeSql.Provider.Odbc/MySql/OdbcMySqlDbFirst.cs @@ -138,8 +138,8 @@ namespace FreeSql.Odbc.MySql public List GetTables(string[] database, string tablename, bool ignoreCase) { var loc1 = new List(); - var loc2 = new Dictionary(); - var loc3 = new Dictionary>(); + var loc2 = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + var loc3 = new Dictionary>(StringComparer.CurrentCultureIgnoreCase); string[] tbname = null; if (string.IsNullOrEmpty(tablename) == false) { @@ -194,7 +194,7 @@ where {(ignoreCase ? "lower(a.table_schema)" : "a.table_schema")} in ({databaseI schema = ""; } loc2.Add(table_id, new DbTableInfo { Id = table_id, Schema = schema, Name = table, Comment = comment, Type = type }); - loc3.Add(table_id, new Dictionary()); + loc3.Add(table_id, new Dictionary(StringComparer.CurrentCultureIgnoreCase)); switch (type) { 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); if (ds == null) return loc1; - var indexColumns = new Dictionary>(); - var uniqueColumns = new Dictionary>(); + var indexColumns = new Dictionary>(StringComparer.CurrentCultureIgnoreCase); + var uniqueColumns = new Dictionary>(StringComparer.CurrentCultureIgnoreCase); foreach (var row in ds) { string table_id = string.Concat(row[0]); @@ -323,14 +323,14 @@ where {(ignoreCase ? "lower(a.table_schema)" : "a.table_schema")} in ({databaseI Dictionary loc10 = null; DbIndexInfo loc11 = null; if (!indexColumns.TryGetValue(table_id, out loc10)) - indexColumns.Add(table_id, loc10 = new Dictionary()); + indexColumns.Add(table_id, loc10 = new Dictionary(StringComparer.CurrentCultureIgnoreCase)); if (!loc10.TryGetValue(index_id, out loc11)) loc10.Add(index_id, loc11 = new DbIndexInfo()); loc11.Columns.Add(new DbIndexColumnInfo { Column = loc9, IsDesc = is_desc }); if (is_unique && !is_primary_key) { if (!uniqueColumns.TryGetValue(table_id, out loc10)) - uniqueColumns.Add(table_id, loc10 = new Dictionary()); + uniqueColumns.Add(table_id, loc10 = new Dictionary(StringComparer.CurrentCultureIgnoreCase)); if (!loc10.TryGetValue(index_id, out loc11)) loc10.Add(index_id, loc11 = new DbIndexInfo()); 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); if (ds == null) return loc1; - var fkColumns = new Dictionary>(); + var fkColumns = new Dictionary>(StringComparer.CurrentCultureIgnoreCase); foreach (var row in ds) { string table_id = string.Concat(row[0]); @@ -389,7 +389,7 @@ where {(ignoreCase ? "lower(a.constraint_schema)" : "a.constraint_schema")} in ( Dictionary loc12 = null; DbForeignInfo loc13 = null; if (!fkColumns.TryGetValue(table_id, out loc12)) - fkColumns.Add(table_id, loc12 = new Dictionary()); + fkColumns.Add(table_id, loc12 = new Dictionary(StringComparer.CurrentCultureIgnoreCase)); if (!loc12.TryGetValue(fk_id, out loc13)) loc12.Add(fk_id, loc13 = new DbForeignInfo { Table = loc2[table_id], ReferencedTable = loc10 }); loc13.Columns.Add(loc9);