remove QuoteStr() usage in dialects (#1364)

This commit is contained in:
BetaCat 2019-07-24 13:22:14 +08:00 committed by Lunny Xiao
parent 9b08f9494f
commit 4b0ff8ad27
2 changed files with 185 additions and 192 deletions

View File

@ -16,191 +16,191 @@ import (
var ( var (
mssqlReservedWords = map[string]bool{ mssqlReservedWords = map[string]bool{
"ADD": true, "ADD": true,
"EXTERNAL": true, "EXTERNAL": true,
"PROCEDURE": true, "PROCEDURE": true,
"ALL": true, "ALL": true,
"FETCH": true, "FETCH": true,
"PUBLIC": true, "PUBLIC": true,
"ALTER": true, "ALTER": true,
"FILE": true, "FILE": true,
"RAISERROR": true, "RAISERROR": true,
"AND": true, "AND": true,
"FILLFACTOR": true, "FILLFACTOR": true,
"READ": true, "READ": true,
"ANY": true, "ANY": true,
"FOR": true, "FOR": true,
"READTEXT": true, "READTEXT": true,
"AS": true, "AS": true,
"FOREIGN": true, "FOREIGN": true,
"RECONFIGURE": true, "RECONFIGURE": true,
"ASC": true, "ASC": true,
"FREETEXT": true, "FREETEXT": true,
"REFERENCES": true, "REFERENCES": true,
"AUTHORIZATION": true, "AUTHORIZATION": true,
"FREETEXTTABLE": true, "FREETEXTTABLE": true,
"REPLICATION": true, "REPLICATION": true,
"BACKUP": true, "BACKUP": true,
"FROM": true, "FROM": true,
"RESTORE": true, "RESTORE": true,
"BEGIN": true, "BEGIN": true,
"FULL": true, "FULL": true,
"RESTRICT": true, "RESTRICT": true,
"BETWEEN": true, "BETWEEN": true,
"FUNCTION": true, "FUNCTION": true,
"RETURN": true, "RETURN": true,
"BREAK": true, "BREAK": true,
"GOTO": true, "GOTO": true,
"REVERT": true, "REVERT": true,
"BROWSE": true, "BROWSE": true,
"GRANT": true, "GRANT": true,
"REVOKE": true, "REVOKE": true,
"BULK": true, "BULK": true,
"GROUP": true, "GROUP": true,
"RIGHT": true, "RIGHT": true,
"BY": true, "BY": true,
"HAVING": true, "HAVING": true,
"ROLLBACK": true, "ROLLBACK": true,
"CASCADE": true, "CASCADE": true,
"HOLDLOCK": true, "HOLDLOCK": true,
"ROWCOUNT": true, "ROWCOUNT": true,
"CASE": true, "CASE": true,
"IDENTITY": true, "IDENTITY": true,
"ROWGUIDCOL": true, "ROWGUIDCOL": true,
"CHECK": true, "CHECK": true,
"IDENTITY_INSERT": true, "IDENTITY_INSERT": true,
"RULE": true, "RULE": true,
"CHECKPOINT": true, "CHECKPOINT": true,
"IDENTITYCOL": true, "IDENTITYCOL": true,
"SAVE": true, "SAVE": true,
"CLOSE": true, "CLOSE": true,
"IF": true, "IF": true,
"SCHEMA": true, "SCHEMA": true,
"CLUSTERED": true, "CLUSTERED": true,
"IN": true, "IN": true,
"SECURITYAUDIT": true, "SECURITYAUDIT": true,
"COALESCE": true, "COALESCE": true,
"INDEX": true, "INDEX": true,
"SELECT": true, "SELECT": true,
"COLLATE": true, "COLLATE": true,
"INNER": true, "INNER": true,
"SEMANTICKEYPHRASETABLE": true, "SEMANTICKEYPHRASETABLE": true,
"COLUMN": true, "COLUMN": true,
"INSERT": true, "INSERT": true,
"SEMANTICSIMILARITYDETAILSTABLE": true, "SEMANTICSIMILARITYDETAILSTABLE": true,
"COMMIT": true, "COMMIT": true,
"INTERSECT": true, "INTERSECT": true,
"SEMANTICSIMILARITYTABLE": true, "SEMANTICSIMILARITYTABLE": true,
"COMPUTE": true, "COMPUTE": true,
"INTO": true, "INTO": true,
"SESSION_USER": true, "SESSION_USER": true,
"CONSTRAINT": true, "CONSTRAINT": true,
"IS": true, "IS": true,
"SET": true, "SET": true,
"CONTAINS": true, "CONTAINS": true,
"JOIN": true, "JOIN": true,
"SETUSER": true, "SETUSER": true,
"CONTAINSTABLE": true, "CONTAINSTABLE": true,
"KEY": true, "KEY": true,
"SHUTDOWN": true, "SHUTDOWN": true,
"CONTINUE": true, "CONTINUE": true,
"KILL": true, "KILL": true,
"SOME": true, "SOME": true,
"CONVERT": true, "CONVERT": true,
"LEFT": true, "LEFT": true,
"STATISTICS": true, "STATISTICS": true,
"CREATE": true, "CREATE": true,
"LIKE": true, "LIKE": true,
"SYSTEM_USER": true, "SYSTEM_USER": true,
"CROSS": true, "CROSS": true,
"LINENO": true, "LINENO": true,
"TABLE": true, "TABLE": true,
"CURRENT": true, "CURRENT": true,
"LOAD": true, "LOAD": true,
"TABLESAMPLE": true, "TABLESAMPLE": true,
"CURRENT_DATE": true, "CURRENT_DATE": true,
"MERGE": true, "MERGE": true,
"TEXTSIZE": true, "TEXTSIZE": true,
"CURRENT_TIME": true, "CURRENT_TIME": true,
"NATIONAL": true, "NATIONAL": true,
"THEN": true, "THEN": true,
"CURRENT_TIMESTAMP": true, "CURRENT_TIMESTAMP": true,
"NOCHECK": true, "NOCHECK": true,
"TO": true, "TO": true,
"CURRENT_USER": true, "CURRENT_USER": true,
"NONCLUSTERED": true, "NONCLUSTERED": true,
"TOP": true, "TOP": true,
"CURSOR": true, "CURSOR": true,
"NOT": true, "NOT": true,
"TRAN": true, "TRAN": true,
"DATABASE": true, "DATABASE": true,
"NULL": true, "NULL": true,
"TRANSACTION": true, "TRANSACTION": true,
"DBCC": true, "DBCC": true,
"NULLIF": true, "NULLIF": true,
"TRIGGER": true, "TRIGGER": true,
"DEALLOCATE": true, "DEALLOCATE": true,
"OF": true, "OF": true,
"TRUNCATE": true, "TRUNCATE": true,
"DECLARE": true, "DECLARE": true,
"OFF": true, "OFF": true,
"TRY_CONVERT": true, "TRY_CONVERT": true,
"DEFAULT": true, "DEFAULT": true,
"OFFSETS": true, "OFFSETS": true,
"TSEQUAL": true, "TSEQUAL": true,
"DELETE": true, "DELETE": true,
"ON": true, "ON": true,
"UNION": true, "UNION": true,
"DENY": true, "DENY": true,
"OPEN": true, "OPEN": true,
"UNIQUE": true, "UNIQUE": true,
"DESC": true, "DESC": true,
"OPENDATASOURCE": true, "OPENDATASOURCE": true,
"UNPIVOT": true, "UNPIVOT": true,
"DISK": true, "DISK": true,
"OPENQUERY": true, "OPENQUERY": true,
"UPDATE": true, "UPDATE": true,
"DISTINCT": true, "DISTINCT": true,
"OPENROWSET": true, "OPENROWSET": true,
"UPDATETEXT": true, "UPDATETEXT": true,
"DISTRIBUTED": true, "DISTRIBUTED": true,
"OPENXML": true, "OPENXML": true,
"USE": true, "USE": true,
"DOUBLE": true, "DOUBLE": true,
"OPTION": true, "OPTION": true,
"USER": true, "USER": true,
"DROP": true, "DROP": true,
"OR": true, "OR": true,
"VALUES": true, "VALUES": true,
"DUMP": true, "DUMP": true,
"ORDER": true, "ORDER": true,
"VARYING": true, "VARYING": true,
"ELSE": true, "ELSE": true,
"OUTER": true, "OUTER": true,
"VIEW": true, "VIEW": true,
"END": true, "END": true,
"OVER": true, "OVER": true,
"WAITFOR": true, "WAITFOR": true,
"ERRLVL": true, "ERRLVL": true,
"PERCENT": true, "PERCENT": true,
"WHEN": true, "WHEN": true,
"ESCAPE": true, "ESCAPE": true,
"PIVOT": true, "PIVOT": true,
"WHERE": true, "WHERE": true,
"EXCEPT": true, "EXCEPT": true,
"PLAN": true, "PLAN": true,
"WHILE": true, "WHILE": true,
"EXEC": true, "EXEC": true,
"PRECISION": true, "PRECISION": true,
"WITH": true, "WITH": true,
"EXECUTE": true, "EXECUTE": true,
"PRIMARY": true, "PRIMARY": true,
"WITHIN": true, "WITHIN": true,
"EXISTS": true, "EXISTS": true,
"PRINT": true, "PRINT": true,
"WRITETEXT": true, "WRITETEXT": true,
"EXIT": true, "EXIT": true,
"PROC": true, "PROC": true,
} }
) )
@ -507,7 +507,7 @@ func (db *mssql) CreateTableSql(table *core.Table, tableName, storeEngine, chars
sql = "IF NOT EXISTS (SELECT [name] FROM sys.tables WHERE [name] = '" + tableName + "' ) CREATE TABLE " sql = "IF NOT EXISTS (SELECT [name] FROM sys.tables WHERE [name] = '" + tableName + "' ) CREATE TABLE "
sql += db.QuoteStr() + tableName + db.QuoteStr() + " (" sql += db.Quote(tableName) + " ("
pkList := table.PrimaryKeys pkList := table.PrimaryKeys

View File

@ -175,13 +175,6 @@ func (engine *Engine) SupportInsertMany() bool {
return engine.dialect.SupportInsertMany() return engine.dialect.SupportInsertMany()
} }
// QuoteStr Engine's database use which character as quote.
// mysql, sqlite use ` and postgres use "
// Deprecated, use Quote() instead
func (engine *Engine) QuoteStr() string {
return engine.dialect.QuoteStr()
}
func (engine *Engine) quoteColumns(columnStr string) string { func (engine *Engine) quoteColumns(columnStr string) string {
columns := strings.Split(columnStr, ",") columns := strings.Split(columnStr, ",")
for i := 0; i < len(columns); i++ { for i := 0; i < len(columns); i++ {