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)
Change History (11)
comment:1 by , 14 years ago
Keywords: | field added; join removed |
---|
comment:2 by , 14 years ago
Summary: | fTools' join attributes fails when renaming 10-char field names → fTools fail to rename duplicated field names if they are 10 char long |
---|
comment:3 by , 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
comment:4 by , 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 , 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 , 14 years ago
Attachment: | trim_and_warnings.diff added |
---|
follow-up: 7 comment:6 by , 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)
comment:7 by , 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 , 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 , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Patch applied in r13313.
Carson
I've just realized it's a common issue in all fTools.