[GRASS-SVN] r67315 - grass/trunk/scripts/v.db.renamecolumn
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Dec 21 17:50:12 PST 2015
Author: martinl
Date: 2015-12-21 17:50:12 -0800 (Mon, 21 Dec 2015)
New Revision: 67315
Modified:
grass/trunk/scripts/v.db.renamecolumn/v.db.renamecolumn.py
Log:
v.db.renamecolumn mysql error (#2819) - applied patch proposed by Markus Neteler
Modified: grass/trunk/scripts/v.db.renamecolumn/v.db.renamecolumn.py
===================================================================
--- grass/trunk/scripts/v.db.renamecolumn/v.db.renamecolumn.py 2015-12-22 01:33:42 UTC (rev 67314)
+++ grass/trunk/scripts/v.db.renamecolumn/v.db.renamecolumn.py 2015-12-22 01:50:12 UTC (rev 67315)
@@ -97,6 +97,14 @@
sql = "UPDATE %s SET %s=%s" % (table, newcol, oldcol)
grass.write_command('db.execute', input = '-', database = database, driver = driver, stdin = sql)
grass.run_command('v.db.dropcolumn', map = map, layer = layer, column = oldcol)
+ 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)
else:
sql = "ALTER TABLE %s RENAME %s TO %s" % (table, oldcol, newcol)
grass.write_command('db.execute', input = '-', database = database, driver = driver, stdin = sql)
More information about the grass-commit
mailing list