Opened 15 years ago
Closed 15 years ago
#75 closed defect (fixed)
v.db.join incorrectly uses v.db.connect and is broken for multi-layered vectors
|Reported by:||tvrusso||Owned by:|
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:
v.db.connect -g $GIS_OPT_MAP layer=$GIS_OPT_LAYER | cut -d' ' -f5"
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:
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.
Change History (1)
comment:1 by , 15 years ago
|Milestone:||6.4.0 → 6.3.0|
|Status:||new → closed|
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.