Skip to content

Commit

Permalink
Surround index column name with brackets
Browse files Browse the repository at this point in the history
Surround column name with brackets to avoid issues when the column name is the same as a reserved keyword (e.g. index)
  • Loading branch information
wismna authored Dec 11, 2024
1 parent c8a6fca commit 80721e3
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object CreateIndex extends Command with Log {
val createIndexParts = rawSql.split("""\s+on\s+""")
val indexName = createIndexParts(0).tokens(INDEX_NAME_POSITION)
val tableName = createIndexParts(1).tokens(TABLE_NAME_POSITION)
val columns = rawSql.takeBraces.head.columns.map(_.name).mkString(",")
val columns = rawSql.takeBraces.head.columns.map(column => s"[${column.name}]").mkString(",")

(tableName, s"CREATE INDEX $indexName ON $tableName ($columns)", columns)
} catch {
Expand Down

0 comments on commit 80721e3

Please sign in to comment.