Bug report #17593

PostgreSQL and virtual fields: can add virtual fields but cannot remove them

Added by Andreas Neumann over 2 years ago. Updated over 2 years ago.

Status:Closed
Priority:High
Assignee:Sandro Santilli
Category:Virtual Fields
Affected QGIS version:master Regression?:Yes
Operating System: Easy fix?:No
Pull Request or Patch supplied:Yes Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:25490

Description

After adding a new virtual field to a PostgreSQL table (layer properties --> source fields) one cannot remove the virtual fields anymore.

May be a side-effect of the "Fields and Forms Redesign" in QGIS master ?

Associated revisions

Revision f5cd8565
Added by Sandro Santilli over 2 years ago

Refresh virtual fields editing button state based on field selection

Allows removing virtual fields defined on read-only PostgreSQL tables.
Closes #17593

History

#1 Updated by Giovanni Manghi over 2 years ago

  • Regression? changed from No to Yes

#2 Updated by Sandro Santilli over 2 years ago

  • Status changed from Open to Feedback
  • Assignee set to Sandro Santilli
  • Resolution set to worksforme

I cannot reproduce with 0f1f24a174.
What I do:
1) Select a PostGIS table, adding it as a layer
2) Go to LayerProperties->SourceFields
3) Click on "Field Calculator" icon
4) Define a new virtual field with formula: 3*2
5) Click on the pencil icon, save changes to layer
6) Click on the pencil icon again
7) Select the new virtual field, click on "delete field" icon
8) Click on the pencil icon, save changes to layer

Does the above work for you ? Please specify your procedure if it still fails for you.

#3 Updated by Andreas Neumann over 2 years ago

Sorry - I need to be more precise.

The issue happens if one adds a Postgis layer without permissions to change the layer.

In this case the fields can only be added as virtual fields (through the field calculator), but due to the missing permissions, one cannot remove the virtual fields anymore.

While the restriction for not being able to remove should apply to physical fields in this case, virtual fields should still be removeable.

Can you reproduce my issue in the case where you lack permissions to edit the PostgreSQL layer?

Thanks,
Andreas

#4 Updated by Andreas Neumann over 2 years ago

Here are the exact steps:

1) Select a PostGIS table, adding it as a layer (make sure you have only select permissions on this layer)
2) Go to LayerProperties->SourceFields
3) Click on "Field Calculator" icon
4) Define a new virtual field with formula: 3*2
5) Press ok in the field calculator
6) Select the new virtual field in the "Source fields" table
7) The "delete field" button is greyed out (inactive)

While this behaviour is correct for physical fields (after all, the user only has SELECT permissions), virtual fields should still be removeable.

So to solve this issue, if a virtual field is selected, the "Delete Field" button should not be greyed out and always active.

#5 Updated by Sandro Santilli over 2 years ago

  • Status changed from Feedback to In Progress
  • Resolution deleted (worksforme)

Yes, I can reproduce.
Will give the fix a try.

#6 Updated by Sandro Santilli over 2 years ago

I confirm it is a regression because 2.18.14 works fine (Delete is NOT greyed out for virtual fields while it is for physical fields)

#7 Updated by Sandro Santilli over 2 years ago

It looks like there's no update of button states on changing attribute selection. Code in 2.18 had a signal handler onAttributeSelectionChanged which is not present in master.

#8 Updated by Sandro Santilli over 2 years ago

  • Pull Request or Patch supplied changed from No to Yes

#9 Updated by Sandro Santilli over 2 years ago

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

#10 Updated by Giovanni Manghi over 2 years ago

  • Resolution set to fixed/implemented

Also available in: Atom PDF