[GRASS-dev] [GRASS GIS] #75: v.db.join incorrectly uses v.db.connect and is broken for multi-layered vectors

#75: v.db.join incorrectly uses v.db.connect and is broken for multi-layered
vectors
---------------------+------------------------------------------------------
Reporter: tvrusso | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: major | Milestone: 6.4.0
Component: default | Version: unspecified
Keywords: |
---------------------+------------------------------------------------------
I attempted to use v.db.join to join a table to the second layer of a
vector that had two layers (two tables connected to it). v.db.join gave
me error messages from db.describe reporting that "<sqlite> is not a valid
parameter" and another reporting that the path to my sqlite database is
not a valid parameter. It turns out that
what was really wrong was that the "driver" and "database" variables that
are set in
v.db.join:

driver="`v.db.connect -g $GIS_OPT_MAP layer=$GIS_OPT_LAYER | cut -d' '
-f5`"
database="`v.db.connect -g $GIS_OPT_MAP layer=$GIS_OPT_LAYER | cut -d' '
-f4`"

on lines 76 and 77 are improperly set to "sqlite sqlite" and
"/my/sqlite/db /my/sqlite/db" --- that is, two copies of each are stored
in the variable. That's because according to the man page, v.db.connect
IGNORES the "layer=" option with the "-g" option and reports all database
connections. Since I have two layers, the commands above produce two
copies of the data, and later, when $driver and $database are used in
command lines they cause problems.

Instead of using layer= to try to select the database and driver with
v.db.connect, a more convoluted command line might be necessary, as for
example:
driver=`v.db.connect -g $GIS_OPT_MAP | head -n $GIS_OPT_LAYER | tail -1 |
cut -d' ' -f5`"

I tested out that kind of modification and it does appear to address the
issue.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/75&gt;
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/

#75: v.db.join incorrectly uses v.db.connect and is broken for multi-layered
vectors
----------------------+-----------------------------------------------------
  Reporter: tvrusso | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: closed
  Priority: major | Milestone: 6.3.0
Component: default | Version: unspecified
Resolution: fixed | Keywords:
----------------------+-----------------------------------------------------
Changes (by hamish):

  * status: new => closed
  * resolution: => fixed
  * milestone: 6.4.0 => 6.3.0

Comment:

Hi,

this should be fixed now in SVN, r30404.

instead of head | tail I used 'grep "^$GIS_OPT_LAYER "'. I see v.db.update
does something similar with 'grep -w "$GIS_OPT_LAYER"'. Either way will do
I guess.

please test & report back.

Hamish

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/75#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/