Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 88f7424

Browse files
committed
Rename ext method to StripDbQuotes to avoid conflicts with SS.Text
1 parent 200c29e commit 88f7424

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

src/ServiceStack.OrmLite.MySql/MySqlDialectProviderBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ public override string ToTableNamesWithRowCountsStatement(bool live, string sche
417417
public override bool DoesTableExist(IDbCommand dbCmd, string tableName, string schema = null)
418418
{
419419
var sql = "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = {0} AND TABLE_SCHEMA = {1}"
420-
.SqlFmt(GetTableName(tableName, schema).StripQuotes(), dbCmd.Connection.Database);
420+
.SqlFmt(GetTableName(tableName, schema).StripDbQuotes(), dbCmd.Connection.Database);
421421

422422
var result = dbCmd.ExecLongScalar(sql);
423423

@@ -429,7 +429,7 @@ public override bool DoesColumnExist(IDbConnection db, string columnName, string
429429
tableName = GetTableName(tableName, schema);
430430
var sql = "SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS"
431431
+ " WHERE TABLE_NAME = @tableName AND COLUMN_NAME = @columnName AND TABLE_SCHEMA = @schema"
432-
.SqlFmt(GetTableName(tableName, schema).StripQuotes(), columnName);
432+
.SqlFmt(GetTableName(tableName, schema).StripDbQuotes(), columnName);
433433

434434
var result = db.SqlScalar<long>(sql, new { tableName, columnName, schema = db.Database });
435435

src/ServiceStack.OrmLite/Expressions/SqlExpression.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2435,7 +2435,7 @@ protected string RemoveQuoteFromAlias(string exp)
24352435
protected virtual bool IsFieldName(object quotedExp)
24362436
{
24372437
var fieldExpr = quotedExp.ToString().StripTablePrefixes();
2438-
var unquotedExpr = fieldExpr.StripQuotes();
2438+
var unquotedExpr = fieldExpr.StripDbQuotes();
24392439

24402440
var isTableField = modelDef.FieldDefinitionsArray
24412441
.Any(x => GetColumnName(x.FieldName) == unquotedExpr);

src/ServiceStack.OrmLite/OrmLiteDialectProviderBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,7 @@ public virtual string ToCreateTableStatement(Type tableType)
13291329
public virtual string GetUniqueConstraints(ModelDefinition modelDef)
13301330
{
13311331
var constraints = modelDef.UniqueConstraints.Map(x =>
1332-
$"CONSTRAINT {GetUniqueConstraintName(x, GetTableName(modelDef).StripQuotes())} UNIQUE ({x.FieldNames.Map(f => modelDef.GetQuotedName(f,this)).Join(",")})" );
1332+
$"CONSTRAINT {GetUniqueConstraintName(x, GetTableName(modelDef).StripDbQuotes())} UNIQUE ({x.FieldNames.Map(f => modelDef.GetQuotedName(f,this)).Join(",")})" );
13331333

13341334
return constraints.Count > 0
13351335
? constraints.Join(",\n")

src/ServiceStack.OrmLite/OrmLiteUtils.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,9 @@ public static string StripTablePrefixes(this string selectExpression)
818818
return StringBuilderCache.ReturnAndFree(sb).Trim();
819819
}
820820

821-
public static char[] QuotedChars = new[] { '"', '`', '[', ']' };
821+
public static char[] QuotedChars = { '"', '`', '[', ']' };
822822

823-
public static string StripQuotes(this string quotedExpr)
823+
public static string StripDbQuotes(this string quotedExpr)
824824
{
825825
return quotedExpr.Trim(QuotedChars);
826826
}
@@ -1117,6 +1117,6 @@ public static string QuotedLiteral(string text) => text == null || text.IndexOf(
11171117
? text
11181118
: "'" + text + "'";
11191119

1120-
public static string UnquotedColumnName(string columnExpr) => columnExpr.LastRightPart('.').StripQuotes();
1120+
public static string UnquotedColumnName(string columnExpr) => columnExpr.LastRightPart('.').StripDbQuotes();
11211121
}
11221122
}

src/ServiceStack.OrmLite/OrmLiteWriteCommandExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ internal static IDbCommand InsertIntoSelectInternal<T>(this IDbCommand dbCmd, IS
743743
.ParseCommands();
744744

745745
var fieldsOrAliases = selectFields
746-
.Map(x => x.Original.ToString().LastRightPart(" AS ").Trim().StripQuotes());
746+
.Map(x => x.Original.ToString().LastRightPart(" AS ").Trim().StripDbQuotes());
747747

748748
dialectProvider.PrepareParameterizedInsertStatement<T>(dbCmd, insertFields: fieldsOrAliases);
749749

tests/ServiceStack.OrmLite.Tests/MetaDataTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public void Can_get_GetTableNamesWithRowCounts_of_keyword_table()
143143
var tableNames = db.GetTableNamesWithRowCounts(live:true);
144144
Assert.That(tableNames.Count, Is.GreaterThan(0));
145145

146-
var table1Name = db.GetDialectProvider().GetTableName(typeof(Order).GetModelMetadata()).StripQuotes();
146+
var table1Name = db.GetDialectProvider().GetTableName(typeof(Order).GetModelMetadata()).StripDbQuotes();
147147

148148
var table1Pos = IndexOf(tableNames, x => x.Key.EqualsIgnoreCase(table1Name) && x.Value == 3);
149149
Assert.That(table1Pos, Is.GreaterThanOrEqualTo(0));
@@ -201,8 +201,8 @@ public void Can_get_GetTableNamesWithRowCounts_in_Schema()
201201
tableNames.TextDump().Print();
202202
Assert.That(tableNames.Count, Is.GreaterThan(0));
203203

204-
var table1Name = db.GetDialectProvider().GetTableName(typeof(Schematable1).GetModelMetadata()).LastRightPart('.').StripQuotes();
205-
var table2Name = db.GetDialectProvider().GetTableName(typeof(Schematable2).GetModelMetadata()).LastRightPart('.').StripQuotes();
204+
var table1Name = db.GetDialectProvider().GetTableName(typeof(Schematable1).GetModelMetadata()).LastRightPart('.').StripDbQuotes();
205+
var table2Name = db.GetDialectProvider().GetTableName(typeof(Schematable2).GetModelMetadata()).LastRightPart('.').StripDbQuotes();
206206

207207
var table1Pos = IndexOf(tableNames, x => x.Key.IndexOf(table1Name, StringComparison.OrdinalIgnoreCase) >=0 && x.Value == 3);
208208
Assert.That(table1Pos, Is.GreaterThanOrEqualTo(0));

tests/ServiceStack.OrmLite.Tests/TemplateDbTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public async Task Can_call_dbSingle_with_param()
3939
db.DropAndCreateTable<Rockstar>();
4040
db.InsertAll(AutoQueryTests.SeedRockstars);
4141

42-
var firstName = "FirstName".SqlColumn(DialectProvider).StripQuotes();
42+
var firstName = "FirstName".SqlColumn(DialectProvider).StripDbQuotes();
4343

4444
var args = new Dictionary<string, object> { { "id", 3 }};
4545

0 commit comments

Comments
 (0)