-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functionality to handle reserved keywords as table and column names
- Add functionality to handle reserved keywords as table and column names - Cleanup Canonicalization - Add unit tests for table with name and column having a reserved keyword
- Loading branch information
1 parent
75fc65e
commit 16c70c4
Showing
7 changed files
with
236 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
namespace Weasel.SqlServer; | ||
|
||
public static class SchemaUtils | ||
{ | ||
public static string QuoteName(string name) | ||
{ | ||
return ReservedKeywords.Contains(name, StringComparer.InvariantCultureIgnoreCase) ? $"[{name}]" : name; | ||
} | ||
|
||
private static readonly string[] ReservedKeywords = | ||
[ | ||
"ADD", | ||
"EXTERNAL", | ||
"PROCEDURE", | ||
"ALL", | ||
"FETCH", | ||
"PUBLIC", | ||
"ALTER", | ||
"FILE", | ||
"RAISERROR", | ||
"AND", | ||
"FILLFACTOR", | ||
"READ", | ||
"ANY", | ||
"FOR", | ||
"READTEXT", | ||
"AS", | ||
"FOREIGN", | ||
"RECONFIGURE", | ||
"ASC", | ||
"FREETEXT", | ||
"REFERENCES", | ||
"AUTHORIZATION", | ||
"FREETEXTTABLE", | ||
"REPLICATION", | ||
"BACKUP", | ||
"FROM", | ||
"RESTORE", | ||
"BEGIN", | ||
"FULL", | ||
"RESTRICT", | ||
"BETWEEN", | ||
"FUNCTION", | ||
"RETURN", | ||
"BREAK", | ||
"GOTO", | ||
"REVERT", | ||
"BROWSE", | ||
"GRANT", | ||
"REVOKE", | ||
"BULK", | ||
"GROUP", | ||
"RIGHT", | ||
"BY", | ||
"HAVING", | ||
"ROLLBACK", | ||
"CASCADE", | ||
"HOLDLOCK", | ||
"ROWCOUNT", | ||
"CASE", | ||
"IDENTITY", | ||
"ROWGUIDCOL", | ||
"CHECK", | ||
"IDENTITY_INSERT", | ||
"RULE", | ||
"CHECKPOINT", | ||
"IDENTITYCOL", | ||
"SAVE", | ||
"CLOSE", | ||
"IF", | ||
"SCHEMA", | ||
"CLUSTERED", | ||
"IN", | ||
"SECURITYAUDIT", | ||
"COALESCE", | ||
"INDEX", | ||
"SELECT", | ||
"COLLATE", | ||
"INNER", | ||
"SEMANTICKEYPHRASETABLE", | ||
"COLUMN", | ||
"INSERT", | ||
"SEMANTICSIMILARITYDETAILSTABLE", | ||
"COMMIT", | ||
"INTERSECT", | ||
"SEMANTICSIMILARITYTABLE", | ||
"COMPUTE", | ||
"INTO", | ||
"SESSION_USER", | ||
"CONSTRAINT", | ||
"IS", | ||
"SET", | ||
"CONTAINS", | ||
"JOIN", | ||
"SETUSER", | ||
"CONTAINSTABLE", | ||
"KEY", | ||
"SHUTDOWN", | ||
"CONTINUE", | ||
"KILL", | ||
"SOME", | ||
"CONVERT", | ||
"LEFT", | ||
"STATISTICS", | ||
"CREATE", | ||
"LIKE", | ||
"SYSTEM_USER", | ||
"CROSS", | ||
"LINENO", | ||
"TABLE", | ||
"CURRENT", | ||
"LOAD", | ||
"TABLESAMPLE", | ||
"CURRENT_DATE", | ||
"MERGE", | ||
"TEXTSIZE", | ||
"CURRENT_TIME", | ||
"NATIONAL", | ||
"THEN", | ||
"CURRENT_TIMESTAMP", | ||
"NOCHECK", | ||
"TO", | ||
"CURRENT_USER", | ||
"NONCLUSTERED", | ||
"TOP", | ||
"CURSOR", | ||
"NOT", | ||
"TRAN", | ||
"DATABASE", | ||
"NULL", | ||
"TRANSACTION", | ||
"DBCC", | ||
"NULLIF", | ||
"TRIGGER", | ||
"DEALLOCATE", | ||
"OF", | ||
"TRUNCATE", | ||
"DECLARE", | ||
"OFF", | ||
"TRY_CONVERT", | ||
"DEFAULT", | ||
"OFFSETS", | ||
"TSEQUAL", | ||
"DELETE", | ||
"ON", | ||
"UNION", | ||
"DENY", | ||
"OPEN", | ||
"UNIQUE", | ||
"DESC", | ||
"OPENDATASOURCE", | ||
"UNPIVOT", | ||
"DISK", | ||
"OPENQUERY", | ||
"UPDATE", | ||
"DISTINCT", | ||
"OPENROWSET", | ||
"UPDATETEXT", | ||
"DISTRIBUTED", | ||
"OPENXML", | ||
"USE", | ||
"DOUBLE", | ||
"OPTION", | ||
"USER", | ||
"DROP", | ||
"OR", | ||
"VALUES", | ||
"DUMP", | ||
"ORDER", | ||
"VARYING", | ||
"ELSE", | ||
"OUTER", | ||
"VIEW", | ||
"END", | ||
"OVER", | ||
"WAITFOR", | ||
"ERRLVL", | ||
"PERCENT", | ||
"WHEN", | ||
"ESCAPE", | ||
"PIVOT", | ||
"WHERE", | ||
"EXCEPT", | ||
"PLAN", | ||
"WHILE", | ||
"EXEC", | ||
"PRECISION", | ||
"WITH", | ||
"EXECUTE", | ||
"PRIMARY", | ||
"WITHIN GROUP", | ||
"EXISTS", | ||
"PRINT", | ||
"WRITETEXT", | ||
"EXIT", | ||
"PROC", | ||
"RANK" | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters