Feature request #9689

Joins should be more mindful of DBF field name length limitations

Added by Emilio G about 10 years ago. Updated almost 8 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Vectors
Pull Request or Patch supplied:No Resolution:fixed/implemented
Easy fix?:No Copied to github as #:18254

Description

When performing a "join" between a DBF file and a shape file, QGIS will prepend the field names with the name of the DBF layer name followed by an underscore.

Surprisingly, layers can have blank names, so that saves some characters. But I still get every field prepended with an underscore.

The table manager plugin will not let you edit field names for those fields that have just been joined; the shape file must be saved and reopened at which point all names have been cropped to the (11?) character limit.

History

#1 Updated by Giovanni Manghi about 10 years ago

  • Category set to Vectors
  • Target version changed from Version 2.2 to Future Release - Nice to have
  • Operating System deleted (Windows 7 x64)

Not an easy task, the prefix is necessary to avoid attributes with the same name, then shapefiles have a 10 chars column name limit. Of course the vector with the joined table can be exported to a more advanced format, like spatialite or postgis where such limitation does not exist.

How do you suggest to solve the issue with shapefiles?

#2 Updated by Emilio G about 10 years ago

The software should simply check if the name is a duplicate. If not, leave it as is. It cannot simply prepend the layer name and hope that this is not a duplicate, so it must be doing some level of checking now, no?

#3 Updated by Jürgen Fischer about 10 years ago

Emilio G wrote:

The software should simply check if the name is a duplicate. If not, leave it as is. It cannot simply prepend the layer name and hope that this is not a duplicate, so it must be doing some level of checking now, no?

It doesn't. There is no restriction before you decide that you want to save the data in a shapefile. And the mapping of arbitrary field names to attributes in shapefiles handled (although it's not as nice as going without a prefix, if that's not necessary for unique field names).

Not sure, if it isn't a bug in the table manager plugin, that it shows joined fields on a shapefile. I believe it wouldn't work with those, even if the names were 11 characters or less.

#4 Updated by Giovanni Manghi about 10 years ago

  • Status changed from Open to Feedback

Emilio G wrote:

The software should simply check if the name is a duplicate. If not, leave it as is. It cannot simply prepend the layer name and hope that this is not a duplicate, so it must be doing some level of checking now, no?

how other software does?

#5 Updated by Antonio Locandro about 10 years ago

When you open the attribute table it shows the join fields as they are unless duplicate I believe it adds a _1 or something to distinguish

Now when doing a Query it adds the layer name + "." + Field to be able to make a difference of one to another

This helps when you save a layer with a join, since the attribute table have the same column names as the join fields if possible

#6 Updated by Nyall Dawson almost 8 years ago

  • Resolution set to fixed/implemented
  • Status changed from Feedback to Closed

QGIS supports custom prefixes for joined layers, so this should be fixed now

Also available in: Atom PDF