Bug report #16967
value relation widget with Allow multiple selection doesn't resolve the values anymore
Status: | Closed | ||
---|---|---|---|
Priority: | High | ||
Assignee: | Alessandro Pasotti | ||
Category: | Edit widget | ||
Affected QGIS version: | master | Regression?: | Yes |
Operating System: | Debian Stretch | Easy fix?: | No |
Pull Request or Patch supplied: | Yes | Resolution: | |
Crashes QGIS or corrupts data: | Yes | Copied to github as #: | 24866 |
Description
Steps to reproduce:
- Add a PostgreSQL layer with a integer[] column
- Add a Value relation layer and point it to the array column
- The values get saved in the DB when creating a feature
- The widget cannot present the values stored in the database when the feature form gets popped and the user can overwrite them without knowing
I've also attached a GIF.
Associated revisions
[bugfix] value relation widget with Allow multiple selection doesn't resolve
Now it will accept arrays as well as string representations of arrays
Added a test
Fixes #16967 value relation widget with Allow multiple selection doesn't resolve the values anymore
History
#1 Updated by Giovanni Manghi over 7 years ago
- Priority changed from Normal to High
#2 Updated by Matthias Kuhn about 7 years ago
Tudor, any chance you can provide a sample database and project?
#3 Updated by Tudor Bărăscu about 7 years ago
- File bug.jpg added
Sure!
I think instead of a dump and a project it's easier to just create the tables:
CREATE TABLE test (id serial PRIMARY KEY, location integer[], geom geometry(Point, 4326));
CREATE TABLE location_type (id serial PRIMARY KEY, value text);
INSERT INTO location_type (value) VALUES ('sidewalk');
INSERT INTO location_type (value) VALUES ('asphalt');
INSERT INTO location_type (value) VALUES ('sand');
INSERT INTO location_type (value) VALUES ('soil');]]
add the layers in a project, and configure the location widget as a value relation like so:
Then, add a new point and select some of the locations.
They will get saved in the database.
However, opening the form on the same point shows an empty location part.
Thanks!
#5 Updated by Luigi Pirelli almost 7 years ago
seems the error is here:
https://github.com/qgis/QGIS/blob/master/src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp#L57
misformatting the string list... the result resutn a empty list.
debugging the value is simply an Int array
find the way to correctly generate the keyList
#6 Updated by Alessandro Pasotti almost 7 years ago
- Assignee changed from Luigi Pirelli to Alessandro Pasotti
#7 Updated by Alessandro Pasotti almost 7 years ago
- Status changed from Open to In Progress
- Pull Request or Patch supplied changed from No to Yes
#8 Updated by Anonymous almost 7 years ago
- % Done changed from 0 to 100
- Status changed from In Progress to Closed
Applied in changeset qgis|4f05ed1dd7a9b3eb831efcccd5fe9ebe53cb37d7.