Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v.db.dropcolumn: fix enclosing column name with SQL standard double quotes #3632

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading