Opened 6 years ago

Closed 5 years ago

#2510 closed defect (fixed)

v.db.addcolumn, bad parser syntax in script causes error, cascades to other modules

Reported by: isaacullah Owned by: grass-dev@…
Priority: major Milestone: 7.0.0
Component: Vector Version: svn-releasebranch70
Keywords: parser, v.db.addcolumn Cc:
CPU: x86-64 Platform: Linux

Description

Hi all,

In latest version of 7 from GRASS stable Ubuntu PPA archive, v.db.addcolumn is broken because of a change to the parser code in the script. The error is:

ERROR: Sorry, <map> is not a valid parameter
ERROR: Required parameter <output> not set:
	(Name for output vector map)

But this is because the only options are "output", and "map" and "layer" don't show up. Looking at the script, I see that the relevant parser code in the header is this:

#%module
#% description: Adds one or more columns to the attribute table connected to a given vector map.
#% keywords: vector
#% keywords: attribute table
#% keywords: database
#%end

#%option G_OPT_V_MAP
#%end

#%option G_OPT_V_FIELD
#% label: Layer number where to add column(s)
#%end

#%option
#% key: columns
#% type: string
#% label: Name and type of the new column(s) ('name type [,name type, ...]')
#% description: Data types depend on database backend, but all support VARCHAR(), INT, DOUBLE PRECISION and DATE
#% required: yes
#%end

It's obvious that it's the "G_OPT_V_MAP" and "G_OPT_V_FIELD" that are causing the error. I've not ever used that syntax in my own scripts (I wasn't aware that one *cold* do that, actually), but th error is fixed by changing to the "normal" parser syntax:

#%module
#% description: Adds one or more columns to the attribute table connected to a given vector map.
#% keywords: vector
#% keywords: attribute table
#% keywords: database
#%end

#%option
#% key: map
#% type: string
#% gisprompt: old,vector,vector
#% label: Name of map to add columns to the database
#% required: yes
#%end

#%option
#% key: layer
#% type: integer
#% label: Layer number where to add column(s)
#% answer: 1
#% required: yes
#%end

#%option
#% key: columns
#% type: string
#% label: Name and type of the new column(s) ('name type [,name type, ...]')
#% description: Data types depend on database backend, but all support VARCHAR(), INT, DOUBLE PRECISION and DATE
#% required: yes
#%end

Not sure if the v.db.addcolumn code was always like that, and the error is caused by some other change, or if this is due to a recent change to the script itself, but it seems like an easy fix. This is a serious bug because it breaks a lot of the other vector tools.

Change History (3)

comment:1 in reply to:  description Changed 6 years ago by neteler

Keywords: v.db.addcolumn added; syntax error script removed

Replying to isaacullah:

Hi all,

In latest version of 7 from GRASS stable Ubuntu PPA archive, v.db.addcolumn is broken because of a change to the parser code in the script. The error is:

ERROR: Sorry, <map> is not a valid parameter
ERROR: Required parameter <output> not set:
	(Name for output vector map)

Is it really the latest you are using there? We have made a major code cleanup, perhaps the package was created in the "transition days"?

I just tried, works fine with the really current version:

GRASS 7.0.0svn (nc_spm_08_grass7):~ > v.db.addcolumn random column="el102 double precision"
GRASS 7.0.0svn (nc_spm_08_grass7):~ > g.version -g
version=7.0.0svn
date=2014
revision=63285M
build_date=2014-12-03
build_platform=x86_64-unknown-linux-gnu

comment:2 Changed 5 years ago by mlennert

Can we close this ? I also get the map parameter as expected.

comment:3 Changed 5 years ago by neteler

Resolution: fixed
Status: newclosed

Closing, reopen if needed.

Note: See TracTickets for help on using tickets.