Skip to content

Commit

Permalink
v.db.dropcolumn: fix enclosing column name with SQL standard double q…
Browse files Browse the repository at this point in the history
…uotes (#3632)
  • Loading branch information
tmszi authored and neteler committed Apr 23, 2024
1 parent 2bd3c6d commit 77e8325
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scripts/v.db.dropcolumn/v.db.dropcolumn.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ def main():
# see db_sqltype_name() for type names
if f[1] == "CHARACTER":
# preserve field length for sql type "CHARACTER"
coltypes.append("%s %s(%s)" % (f[0], f[1], f[2]))
coltypes.append(f'"{f[0]}" {f[1]}({f[2]})')
else:
coltypes.append("%s %s" % (f[0], f[1]))
coltypes.append(f'"{f[0]}" {f[1]}')

colnames = ", ".join(colnames)
colnames = ", ".join([f'"{col}"' for col in colnames])
coltypes = ", ".join(coltypes)

cmds = [
Expand All @@ -119,7 +119,7 @@ def main():
table=table, coldef=coltypes, colnames=colnames, keycol=keycol
)
else:
sql = "ALTER TABLE %s DROP COLUMN %s" % (table, column)
sql = f'ALTER TABLE {table} DROP COLUMN "{column}"'

try:
grass.write_command(
Expand Down

0 comments on commit 77e8325

Please sign in to comment.