[GRASS-dev] [GRASS GIS] #3071: v.db.join: fails with SQLite because of lower/UPPER case issues
GRASS GIS
trac at osgeo.org
Thu Jun 23 14:18:00 PDT 2016
#3071: v.db.join: fails with SQLite because of lower/UPPER case issues
-------------------------+-------------------------
Reporter: sbl | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone: 7.0.5
Component: Default | Version: unspecified
Keywords: | CPU: Unspecified
Platform: Unspecified |
-------------------------+-------------------------
v.db.join fails when target and other table have columns with the same
names but different cases: e.g. ID and id
Here is an example to reproduce:
{{{
wget -N http://www.grassbook.org/wp-
content/uploads/ncexternal/nc_geology.csv
# check original map attributes
v.db.select geology column=GEO_NAME,SHAPE_area
# import of CSV table
db.in.ogr input=nc_geology.csv output=nc_geology
# work on copy of geology map in current mapset
g.copy vector=geology,mygeology
# Add uppercase column, which are lowercase in other table
v.db.addcolumn map=mygeology column="GEOL_ID text"
v.db.addcolumn map=mygeology column="LONGNAME text"
# Fill join column
v.db.update map=mygeology column=GEOL_ID query_column=GEO_NAME
# check column names of vector map attributes
v.info -c mygeology
# check column names of legend table
db.describe -c nc_geology
# join table using key columns (map: "GEOL_ID"; table: "geol_id")
v.db.join map=mygeology column=GEOL_ID other_table=nc_geology
other_column=geol_id
}}}
Please find attached a diff which should fix the issue.
However column case handling might need some more deliberation, since e.g.
PostgreSQL handles uppercase column names (when quoted).
So comparing column names case-insensitive (as in the diff) is probably
only a hack...?
Finally, I was wondering if it is OK that v.db.join possibly overwrites
data in the target if both have column names in common (e.g. "cat")...
Maybe better to add a flag to allow overwriting column content?
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3071>
GRASS GIS <https://grass.osgeo.org>
More information about the grass-dev
mailing list