Opened 12 years ago

Last modified 3 years ago

#1393 new defect

v.db.join and "duplicate column name"

Reported by: lucadelu Owned by: grass-dev@…
Priority: major Milestone: 7.8.3
Component: Vector Version: unspecified
Keywords: vector db join Cc:
CPU: Unspecified Platform: All

Description

Today I found a problem when I try to join tables with v.db.join. The problem was that the key columns have the same name and the join returned an error.

v.db.join map=confini_provinciali column=PROV otable=tabprovince ocol=PROV

DBMI-SQLite driver error:
Error in sqlite3_prepare():
duplicate column name: PROV

ERROR: Error while executing: 'ALTER TABLE confini_provinciali ADD COLUMN
       PROV CHARACTER
       '
ERROR: Cannot continue (problem adding column).
ERROR: Cannot continue.

To solve this problem I adding two flag that they permit to pass it. One permit to not copy the join column, the data of join column are already present on the map table; the other flag permit to copy all the column from other_table adding "_o" to the columns name. This is the idea used by v.overlay that add "_a" at the columns of ainput and "_b" for the columns of binput. In attachment you can found the patch, test it and if you think that it's a good solution please add it to the svn

Attachments (2)

vdbjoin.patch (1.5 KB ) - added by lucadelu 12 years ago.
sorry the patch before was wrong
v_db_join_colprefix.diff (3.0 KB ) - added by mlennert 4 years ago.

Download all attachments as: .zip

Change History (9)

by lucadelu, 12 years ago

Attachment: vdbjoin.patch added

sorry the patch before was wrong

comment:1 by neteler, 7 years ago

Milestone: 6.4.26.4.6

comment:2 by mlennert, 4 years ago

I'm attaching a patch to the current Python version of v.db.join that does the following:

  • add a 'column_prefix' parameter that allows defining a column prefix for all newly joined columns in order to avoid any column name conflicts
  • never join the key column from the other table as that would be redundant

Any objections against applying this ?

by mlennert, 4 years ago

Attachment: v_db_join_colprefix.diff added

comment:3 by mlennert, 4 years ago

Milestone: 6.4.67.8.0

comment:4 by neteler, 3 years ago

Milestone: 7.8.07.8.1

Ticket retargeted after milestone closed

comment:5 by neteler, 3 years ago

Milestone: 7.8.17.8.2

Ticket retargeted after milestone closed

comment:6 by neteler, 3 years ago

Milestone: 7.8.2

Ticket retargeted after milestone closed

comment:7 by neteler, 3 years ago

Milestone: 7.8.3
Note: See TracTickets for help on using tickets.