Opened 14 years ago

Closed 14 years ago

#2629 closed bug (fixed)

fTools fail to rename duplicated field names if they are 10 char long

Reported by: borysiasty Owned by: cfarmer
Priority: major: does not work as expected Milestone: Version 1.5.0
Component: Python plugins and bindings Version: Trunk
Keywords: fTools rename common field name Cc:
Must Fix for Release: No Platform: All
Platform Version: Awaiting user input: no

Description

If I join two tables containing common 10-char-long field name, fTools try to add the "_" char to one of them, then truncate it and fail to write, with no warning message. Could it rename the field name in a more robust way or at least warn that the layer won't be created and why?

Attachments (2)

add_warnings.diff (7.3 KB ) - added by alexbruy 14 years ago.
proposed patch
trim_and_warnings.diff (7.7 KB ) - added by alexbruy 14 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 by borysiasty, 14 years ago

Keywords: field added; join removed

I've just realized it's a common issue in all fTools.

comment:2 by borysiasty, 14 years ago

Summary: fTools' join attributes fails when renaming 10-char field namesfTools fail to rename duplicated field names if they are 10 char long

comment:3 by alexbruy, 14 years ago

This is not an fTools issue, this is limitation of ESRI Shapefile format (exactly DBF format). Field name must be <= 10 characters.

Here is patch to add some warnings to the "Join by attributes" and "Spatial join" tools

by alexbruy, 14 years ago

Attachment: add_warnings.diff added

proposed patch

comment:4 by borysiasty, 14 years ago

The warnings are necessary, but I still suggest to truncate names to 8 characters before adding the suffix. It's extremely easy to implement and can help in many cases (not in all, of course).

comment:5 by alexbruy, 14 years ago

Ok, here is another patch. Long names are truncated to 8 characters and then suffix added. But in this case warning are not necessary I think and we can remove it.

by alexbruy, 14 years ago

Attachment: trim_and_warnings.diff added

comment:6 by borysiasty, 14 years ago

They're still necessary, as one can have more than 2 affected fields. E.g. both "foobarfoo1" and "foobarfoo2" in both tables. It would be the best to add a computed suffix _(n+1) (thought it's still not ideal, as it could cause confusions)

in reply to:  6 comment:7 by alexbruy, 14 years ago

Replying to borysiasty:

It would be the best to add a computed suffix _(n+1) (thought it's still not ideal, as it could cause confusions)

As far as I see computed suffixes _(n+1) are used

comment:8 by borysiasty, 14 years ago

Sorry, my fault! I've look too briefly into the code!

Anyway, I believe we should keep the warnings for a case if one has more than 9 very long names with common prefix in a non-dbf table (e.g. fobarfoo_temperature, fobarfoo_precipitation etc).

comment:9 by cfarmer, 14 years ago

Resolution: fixed
Status: newclosed

Patch applied in r13313.

Carson

Note: See TracTickets for help on using tickets.