[GRASS-dev] [GRASS GIS] #2819: v.db.renamecolumn mysql error

#2819: v.db.renamecolumn mysql error
---------------------------------+-------------------------
Reporter: fpouw | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.3
Component: Database | Version: 7.0.2
Keywords: rename column mysql | CPU: x86-64
Platform: Linux |
---------------------------------+-------------------------
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)

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2819&gt;
GRASS GIS <https://grass.osgeo.org>

#2819: v.db.renamecolumn mysql error
-----------------------+---------------------------------
  Reporter: fpouw | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.3
Component: Database | Version: 7.0.2
Resolution: | Keywords: rename column mysql
       CPU: x86-64 | Platform: Linux
-----------------------+---------------------------------
Changes (by neteler):

* Attachment "v.db.renamecolumn.diff" added.

proposed mysql fix as diff

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2819&gt;
GRASS GIS <https://grass.osgeo.org>

#2819: v.db.renamecolumn mysql error
-----------------------+---------------------------------
  Reporter: fpouw | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.3
Component: Database | Version: 7.0.2
Resolution: | Keywords: rename column mysql
       CPU: x86-64 | Platform: Linux
-----------------------+---------------------------------

Comment (by neteler):

See also #2759

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2819#comment:1&gt;
GRASS GIS <https://grass.osgeo.org>

#2819: v.db.renamecolumn mysql error
-----------------------+---------------------------------
  Reporter: fpouw | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.3
Component: Database | Version: 7.0.2
Resolution: | Keywords: rename column mysql
       CPU: x86-64 | Platform: Linux
-----------------------+---------------------------------

Comment (by martinl):

I tested patch and took liberty to apply r67315.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2819#comment:2&gt;
GRASS GIS <https://grass.osgeo.org>

#2819: v.db.renamecolumn mysql error
-----------------------+---------------------------------
  Reporter: fpouw | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.0.3
Component: Database | Version: 7.0.2
Resolution: fixed | Keywords: rename column mysql
       CPU: x86-64 | Platform: Linux
-----------------------+---------------------------------
Changes (by martinl):

* status: new => closed
* resolution: => fixed

Comment:

Backported in r67360. Closing ticket.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2819#comment:3&gt;
GRASS GIS <https://grass.osgeo.org>