Opened 9 years ago

Closed 9 years ago

#2819 closed defect (fixed)

v.db.renamecolumn mysql error

Reported by: fpouw Owned by: grass-dev@…
Priority: normal Milestone: 7.0.3
Component: Database Version: 7.0.2
Keywords: rename column mysql Cc:
CPU: x86-64 Platform: Linux

Description

The SQL in the v.db.renamecolumn package is not correct for mysql

Adding the following elif command to the "#some tricks" section enables renaming (at least for varchar column type. I didn't test it for other types)

elif driver in mysql:

if oldcoltype.upper() == "CHARACTER":

newcoltype = "varchar(%s)" % (oldcollength)

else:

newcoltype = oldcoltype

sql = "ALTER TABLE %s CHANGE %s %s %s" % (table, oldcol, newcol, newcoltype) grass.write_command('db.execute', input = '-', database = database, driver = driver, stdin = sql)

Attachments (1)

v.db.renamecolumn.diff (1.1 KB ) - added by neteler 9 years ago.
proposed mysql fix as diff

Download all attachments as: .zip

Change History (4)

by neteler, 9 years ago

Attachment: v.db.renamecolumn.diff added

proposed mysql fix as diff

comment:1 by neteler, 9 years ago

See also #2759

comment:2 by martinl, 9 years ago

I tested patch and took liberty to apply r67315.

comment:3 by martinl, 9 years ago

Resolution: fixed
Status: newclosed

Backported in r67360. Closing ticket.

Note: See TracTickets for help on using tickets.