From 6498c7e3000fc5997e460f4dfa87578845192d20 Mon Sep 17 00:00:00 2001 From: Tomas Zigo <50632337+tmszi@users.noreply.github.com> Date: Sat, 20 Apr 2024 08:34:12 +0200 Subject: [PATCH] v.db.dropcolumn: fix enclosing column name with SQL standard double quotes (#3632) --- scripts/v.db.dropcolumn/v.db.dropcolumn.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/v.db.dropcolumn/v.db.dropcolumn.py b/scripts/v.db.dropcolumn/v.db.dropcolumn.py index 937f573006c..b408c83395a 100755 --- a/scripts/v.db.dropcolumn/v.db.dropcolumn.py +++ b/scripts/v.db.dropcolumn/v.db.dropcolumn.py @@ -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 = [ @@ -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(