[GRASS-SVN] r70634 - grass/trunk/scripts/v.db.addtable
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Feb 19 17:47:37 PST 2017
Author: hcho
Date: 2017-02-19 17:47:37 -0800 (Sun, 19 Feb 2017)
New Revision: 70634
Modified:
grass/trunk/scripts/v.db.addtable/v.db.addtable.py
Log:
v.db.addtable: Check for duplicate column names
Modified: grass/trunk/scripts/v.db.addtable/v.db.addtable.py
===================================================================
--- grass/trunk/scripts/v.db.addtable/v.db.addtable.py 2017-02-20 01:15:14 UTC (rev 70633)
+++ grass/trunk/scripts/v.db.addtable/v.db.addtable.py 2017-02-20 01:47:37 UTC (rev 70634)
@@ -106,15 +106,21 @@
stderr=nuldev)
if not table in tables.splitlines():
+ colnames = []
if columns:
- column_def = [x.strip().lower() for x in columns.strip().split(',')]
+ column_def = []
+ for x in ' '.join(columns.lower().split()).split(','):
+ colname = x.split()[0]
+ if colname in colnames:
+ grass.fatal(_("Duplicate column name '%s' not allowed") % colname)
+ colnames.append(colname)
+ column_def.append(x)
else:
column_def = []
# if not existing, create it:
- column_def_key = "%s integer" % key
- if column_def_key not in column_def:
- column_def.insert(0, column_def_key)
+ if not key in colnames:
+ column_def.insert(0, "%s integer" % key)
column_def = ','.join(column_def)
grass.verbose(_("Creating table with columns (%s)...") % column_def)
More information about the grass-commit
mailing list