Skip to content

Commit 30b20c3

Browse files
committed
- fix: CustomAdapter
1 parent f6e1c60 commit 30b20c3

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

Providers/FreeSql.Provider.Custom/CustomUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public override DbParameter[] GetDbParamtersByObject(string sql, object obj) =>
4040
});
4141

4242
static FreeSql.Custom.CustomAdo _customAdo = new FreeSql.Custom.CustomAdo();
43-
public override string FormatSql(string sql, params object[] args) => _customAdo.Addslashes(sql, args);
43+
public override string FormatSql(string sql, params object[] args) => (_orm?.Ado as CustomAdo)?.Addslashes(sql, args) ?? _customAdo.Addslashes(sql, args);
4444
public override string QuoteSqlName(params string[] name)
4545
{
4646
if (name.Length == 1)

Providers/FreeSql.Provider.MySql/MySqlDbFirst.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ public bool ExistsTable(string name, bool ignoreCase)
172172
public List<DbTableInfo> GetTables(string[] database, string tablename, bool ignoreCase)
173173
{
174174
var loc1 = new List<DbTableInfo>();
175-
var loc2 = new Dictionary<string, DbTableInfo>();
176-
var loc3 = new Dictionary<string, Dictionary<string, DbColumnInfo>>();
175+
var loc2 = new Dictionary<string, DbTableInfo>(StringComparer.CurrentCultureIgnoreCase);
176+
var loc3 = new Dictionary<string, Dictionary<string, DbColumnInfo>>(StringComparer.CurrentCultureIgnoreCase);
177177
string[] tbname = null;
178178
if (string.IsNullOrEmpty(tablename) == false)
179179
{
@@ -228,7 +228,7 @@ from information_schema.tables a
228228
schema = "";
229229
}
230230
loc2.Add(table_id, new DbTableInfo { Id = table_id, Schema = schema, Name = table, Comment = comment, Type = type });
231-
loc3.Add(table_id, new Dictionary<string, DbColumnInfo>());
231+
loc3.Add(table_id, new Dictionary<string, DbColumnInfo>(StringComparer.CurrentCultureIgnoreCase));
232232
switch (type)
233233
{
234234
case DbTableType.TABLE:
@@ -337,8 +337,8 @@ from information_schema.statistics a
337337
ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
338338
if (ds == null) return loc1;
339339

340-
var indexColumns = new Dictionary<string, Dictionary<string, DbIndexInfo>>();
341-
var uniqueColumns = new Dictionary<string, Dictionary<string, DbIndexInfo>>();
340+
var indexColumns = new Dictionary<string, Dictionary<string, DbIndexInfo>>(StringComparer.CurrentCultureIgnoreCase);
341+
var uniqueColumns = new Dictionary<string, Dictionary<string, DbIndexInfo>>(StringComparer.CurrentCultureIgnoreCase);
342342
foreach (var row in ds)
343343
{
344344
string table_id = string.Concat(row[0]);
@@ -357,14 +357,14 @@ from information_schema.statistics a
357357
Dictionary<string, DbIndexInfo> loc10 = null;
358358
DbIndexInfo loc11 = null;
359359
if (!indexColumns.TryGetValue(table_id, out loc10))
360-
indexColumns.Add(table_id, loc10 = new Dictionary<string, DbIndexInfo>());
360+
indexColumns.Add(table_id, loc10 = new Dictionary<string, DbIndexInfo>(StringComparer.CurrentCultureIgnoreCase));
361361
if (!loc10.TryGetValue(index_id, out loc11))
362362
loc10.Add(index_id, loc11 = new DbIndexInfo());
363363
loc11.Columns.Add(new DbIndexColumnInfo { Column = loc9, IsDesc = is_desc });
364364
if (is_unique && !is_primary_key)
365365
{
366366
if (!uniqueColumns.TryGetValue(table_id, out loc10))
367-
uniqueColumns.Add(table_id, loc10 = new Dictionary<string, DbIndexInfo>());
367+
uniqueColumns.Add(table_id, loc10 = new Dictionary<string, DbIndexInfo>(StringComparer.CurrentCultureIgnoreCase));
368368
if (!loc10.TryGetValue(index_id, out loc11))
369369
loc10.Add(index_id, loc11 = new DbIndexInfo());
370370
loc11.Columns.Add(new DbIndexColumnInfo { Column = loc9, IsDesc = is_desc });
@@ -400,7 +400,7 @@ from information_schema.key_column_usage a
400400
ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
401401
if (ds == null) return loc1;
402402

403-
var fkColumns = new Dictionary<string, Dictionary<string, DbForeignInfo>>();
403+
var fkColumns = new Dictionary<string, Dictionary<string, DbForeignInfo>>(StringComparer.CurrentCultureIgnoreCase);
404404
foreach (var row in ds)
405405
{
406406
string table_id = string.Concat(row[0]);
@@ -423,7 +423,7 @@ from information_schema.key_column_usage a
423423
Dictionary<string, DbForeignInfo> loc12 = null;
424424
DbForeignInfo loc13 = null;
425425
if (!fkColumns.TryGetValue(table_id, out loc12))
426-
fkColumns.Add(table_id, loc12 = new Dictionary<string, DbForeignInfo>());
426+
fkColumns.Add(table_id, loc12 = new Dictionary<string, DbForeignInfo>(StringComparer.CurrentCultureIgnoreCase));
427427
if (!loc12.TryGetValue(fk_id, out loc13))
428428
loc12.Add(fk_id, loc13 = new DbForeignInfo { Table = loc2[table_id], ReferencedTable = loc10 });
429429
loc13.Columns.Add(loc9);

Providers/FreeSql.Provider.Odbc/MySql/OdbcMySqlDbFirst.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ public bool ExistsTable(string name, bool ignoreCase)
138138
public List<DbTableInfo> GetTables(string[] database, string tablename, bool ignoreCase)
139139
{
140140
var loc1 = new List<DbTableInfo>();
141-
var loc2 = new Dictionary<string, DbTableInfo>();
142-
var loc3 = new Dictionary<string, Dictionary<string, DbColumnInfo>>();
141+
var loc2 = new Dictionary<string, DbTableInfo>(StringComparer.CurrentCultureIgnoreCase);
142+
var loc3 = new Dictionary<string, Dictionary<string, DbColumnInfo>>(StringComparer.CurrentCultureIgnoreCase);
143143
string[] tbname = null;
144144
if (string.IsNullOrEmpty(tablename) == false)
145145
{
@@ -194,7 +194,7 @@ from information_schema.tables a
194194
schema = "";
195195
}
196196
loc2.Add(table_id, new DbTableInfo { Id = table_id, Schema = schema, Name = table, Comment = comment, Type = type });
197-
loc3.Add(table_id, new Dictionary<string, DbColumnInfo>());
197+
loc3.Add(table_id, new Dictionary<string, DbColumnInfo>(StringComparer.CurrentCultureIgnoreCase));
198198
switch (type)
199199
{
200200
case DbTableType.TABLE:
@@ -303,8 +303,8 @@ from information_schema.statistics a
303303
ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
304304
if (ds == null) return loc1;
305305

306-
var indexColumns = new Dictionary<string, Dictionary<string, DbIndexInfo>>();
307-
var uniqueColumns = new Dictionary<string, Dictionary<string, DbIndexInfo>>();
306+
var indexColumns = new Dictionary<string, Dictionary<string, DbIndexInfo>>(StringComparer.CurrentCultureIgnoreCase);
307+
var uniqueColumns = new Dictionary<string, Dictionary<string, DbIndexInfo>>(StringComparer.CurrentCultureIgnoreCase);
308308
foreach (var row in ds)
309309
{
310310
string table_id = string.Concat(row[0]);
@@ -323,14 +323,14 @@ from information_schema.statistics a
323323
Dictionary<string, DbIndexInfo> loc10 = null;
324324
DbIndexInfo loc11 = null;
325325
if (!indexColumns.TryGetValue(table_id, out loc10))
326-
indexColumns.Add(table_id, loc10 = new Dictionary<string, DbIndexInfo>());
326+
indexColumns.Add(table_id, loc10 = new Dictionary<string, DbIndexInfo>(StringComparer.CurrentCultureIgnoreCase));
327327
if (!loc10.TryGetValue(index_id, out loc11))
328328
loc10.Add(index_id, loc11 = new DbIndexInfo());
329329
loc11.Columns.Add(new DbIndexColumnInfo { Column = loc9, IsDesc = is_desc });
330330
if (is_unique && !is_primary_key)
331331
{
332332
if (!uniqueColumns.TryGetValue(table_id, out loc10))
333-
uniqueColumns.Add(table_id, loc10 = new Dictionary<string, DbIndexInfo>());
333+
uniqueColumns.Add(table_id, loc10 = new Dictionary<string, DbIndexInfo>(StringComparer.CurrentCultureIgnoreCase));
334334
if (!loc10.TryGetValue(index_id, out loc11))
335335
loc10.Add(index_id, loc11 = new DbIndexInfo());
336336
loc11.Columns.Add(new DbIndexColumnInfo { Column = loc9, IsDesc = is_desc });
@@ -366,7 +366,7 @@ from information_schema.key_column_usage a
366366
ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
367367
if (ds == null) return loc1;
368368

369-
var fkColumns = new Dictionary<string, Dictionary<string, DbForeignInfo>>();
369+
var fkColumns = new Dictionary<string, Dictionary<string, DbForeignInfo>>(StringComparer.CurrentCultureIgnoreCase);
370370
foreach (var row in ds)
371371
{
372372
string table_id = string.Concat(row[0]);
@@ -389,7 +389,7 @@ from information_schema.key_column_usage a
389389
Dictionary<string, DbForeignInfo> loc12 = null;
390390
DbForeignInfo loc13 = null;
391391
if (!fkColumns.TryGetValue(table_id, out loc12))
392-
fkColumns.Add(table_id, loc12 = new Dictionary<string, DbForeignInfo>());
392+
fkColumns.Add(table_id, loc12 = new Dictionary<string, DbForeignInfo>(StringComparer.CurrentCultureIgnoreCase));
393393
if (!loc12.TryGetValue(fk_id, out loc13))
394394
loc12.Add(fk_id, loc13 = new DbForeignInfo { Table = loc2[table_id], ReferencedTable = loc10 });
395395
loc13.Columns.Add(loc9);

0 commit comments

Comments
 (0)