Skip to content

Commit e1c75de

Browse files
authored
Escape schema name and table name because the query fails if they contain dots (#18)
Thank you for the PR
1 parent 3177e41 commit e1c75de

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/Pomelo.Extensions.Caching.MySql/MySqlQueries.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ internal class MySqlQueries
5252
public MySqlQueries(string schemaName, string tableName)
5353
{
5454
var tableNameWithSchema = string.Format(
55-
"{0}.{1}", DelimitIdentifier(schemaName), DelimitIdentifier(tableName));
55+
"{0}.{1}", EscapeIdentifier(DelimitIdentifier(schemaName)), EscapeIdentifier(DelimitIdentifier(tableName)));
5656

5757
// when retrieving an item, we do an UPDATE first and then a SELECT
5858
GetCacheItem = string.Format(UpdateCacheItemFormat + GetCacheItemFormat, tableNameWithSchema);
@@ -85,5 +85,10 @@ private string EscapeLiteral(string literal)
8585
{
8686
return literal.Replace("'", "''");
8787
}
88+
89+
private string EscapeIdentifier(string identifier)
90+
{
91+
return $"`{identifier}`";
92+
}
8893
}
8994
}

0 commit comments

Comments
 (0)