Browse Source

pythonlib: v.db.select wrapper: do not add key column when we don't want it

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@57914 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 11 years ago
parent
commit
fca31e1a46
1 changed files with 10 additions and 1 deletions
  1. 10 1
      lib/python/script/vector.py

+ 10 - 1
lib/python/script/vector.py

@@ -239,9 +239,11 @@ def vector_db_select(map, layer = 1, **kwargs):
                   { 'layer' : layer, 'map' : map })
         return { 'columns' : [], 'values' : {} }
         
+    include_key = True
     if 'columns' in kwargs:
         if key not in kwargs['columns'].split(','):
             # add key column if missing
+            include_key = False
             debug("Adding key column to the output")
             kwargs['columns'] += ',' + key
     
@@ -260,11 +262,18 @@ def vector_db_select(map, layer = 1, **kwargs):
         if not columns:
             columns = line.split('|')
             key_index = columns.index(key)
+            # discard key column
+            if not include_key:
+                 columns = columns[:-1]
             continue
         
         value = line.split('|')
         key_value = int(value[key_index])
-        values[key_value] = line.split('|')
+        if not include_key:
+            # discard key column
+            values[key_value] = value[:-1]
+        else:
+            values[key_value] = value
     
     return { 'columns' : columns,
              'values' : values }