Bug report #16967

value relation widget with Allow multiple selection doesn't resolve the values anymore

Added by Tudor Bărăscu over 7 years ago. Updated over 6 years ago.

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.

value_relation_bug.gif (902 KB) Tudor Bărăscu, 2017-08-04 06:41 AM

bug.jpg (62.1 KB) Tudor Bărăscu, 2017-11-07 07:51 AM

Associated revisions

Revision 4f05ed1d
Added by Alessandro Pasotti over 6 years ago

[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

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!

#4 Updated by Luigi Pirelli over 6 years ago

  • Assignee set to Luigi Pirelli

investigating

#5 Updated by Luigi Pirelli over 6 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 over 6 years ago

  • Assignee changed from Luigi Pirelli to Alessandro Pasotti

#7 Updated by Alessandro Pasotti over 6 years ago

  • Status changed from Open to In Progress
  • Pull Request or Patch supplied changed from No to Yes

#8 Updated by Anonymous over 6 years ago

  • % Done changed from 0 to 100
  • Status changed from In Progress to Closed

Also available in: Atom PDF