[GRASS-user] Trouble with v.db.join and sqlite

Glynn Clements glynn at gclements.plus.com
Sun Jun 1 13:56:52 EDT 2008

Moritz Lennert wrote:

> >>>> those are the steps to replicate the problem with NC dataset ( all is done
> >>>> in a new mapset called sqlite):
> >>>>
> >>>> db.connect driver=sqlite
> >>>> database='$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite.db'
> >>>> g.copy vect=urbanarea at PERMANENT,urbanarea
> >>>> v.extract -t input=urbanarea output=urban_point type=point,centroid
> >>>> v.db.addtable urban_point
> >>>>
> >>>> v.db.join map=urbanarea column=cat otable=urban_point ocolumn=cat
> >>>> ..
> >>>> DBMI-SQLite driver error:
> >>>> Error in sqlite3_prepare():
> >>>> duplicate column name: cat
> >>>>
> >>>> ERROR: Error while executing: 'ALTER TABLE urban_point ADD COLUMN cat
> >>>>       INTEGER
> >>>>       '
> >>>> ERROR: Cannot continue (problem adding column).
> >>>> ERROR: Cannot continue.
> >>>>
> >>> Like this it was easy to replicated.
> >>> (Hopefully) fixed in 6.4.develbranch and 7.trunk.
> >> Do I understand correctly that the patch ignores the column if the name 
> >> already exists ? Wouldn't it be more "user-friendly" to rename it ?
> > 
> > I don't know about "user-friendly", but it would be safer to just
> > abort with an error if the column already exists.
> > 
> > If you're going to replace the contents of an existing column, you
> > should only do so if --overwrite is given.
> I'm not speaking about replacing any content. I'm proposing that if you 
> have a column cat in each table, then the second is renamed to something 
> like cat2, so that you can have both in the resulting table.

I think that it would be better to just force the user to pick another
name for the ocolumn= option. That way, the user will know what the
column is named.

Also, in a script, silently renaming the output column may result in
the script silently producing bogus results.

More generally, if there's a problem, you tell the user that there's a
problem, not pretend that there isn't a problem.

AFAICT, the only real flaw with the original script is that the
"duplicate column name: cat" error wasn't especially visible.

Other than that, everything happened as it should have done.

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-user mailing list