Bug report #11574

regression: field calculator not updating PostGIS layers

Added by Gavin Fleming over 9 years ago. Updated about 9 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:-
Category:Field calculator
Affected QGIS version:2.6.0 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:19836

Description

Try to update a field in a (remote) PostGIS layer using the field calculator and no visible change occurs, neither does the layer pick up that there are any changes to save.

I have tested this on the same record from the same database and it works in 2.4 and fails in 2.6 and master.

The one that does not work in 2.6 but does work in 2.4 happens to be on a remote host and PostgreSQL 9.1, PostGIS 2.1

2.6 however does work on local host PostgreSQL 9.3 PostGIS 2.1.

The expression I used was simply assigning a new string in ''


Related issues

Related to QGIS Application - Bug report #11538: Field Calculator cannot update certain PostGIS tables Closed 2014-11-03

History

#1 Updated by Giovanni Manghi over 9 years ago

  • Category set to Data Provider/PostGIS
  • Status changed from Open to Feedback
  • Affected QGIS version changed from 2.6.0 to master

Just tested here, both on Linux and Windows, qgis 2.6/master using a remote postgis server, no issues: changes shows immediately in the table of attributes (unless you reordered one of the fields, known issue and regression) and saving edits works fine (close and reopen the table and new values are there).

#2 Updated by Gavin Fleming over 9 years ago

  • Category deleted (Data Provider/PostGIS)
  • Affected QGIS version changed from master to 2.6.0

#3 Updated by Gavin Fleming over 9 years ago

several users on windows working on the same database in an office LAN environment have reported the same issue. I just tested and confirmed it on Linux over the Internet.

#4 Updated by Giovanni Manghi over 9 years ago

  • Affected QGIS version changed from 2.6.0 to master

Gavin Fleming wrote:

several users on windows working on the same database in an office LAN environment have reported the same issue. I just tested and confirmed it on Linux over the Internet.

may be an issue with the permissions in the database?

#5 Updated by Gavin Fleming over 9 years ago

  • Affected QGIS version changed from master to 2.6.0

no I tested as superuser on the same layer filtered to one record. The only difference was the QGIS version.

#6 Updated by Giovanni Manghi over 9 years ago

  • Affected QGIS version changed from 2.6.0 to master
  • Category set to Data Provider/PostGIS
  • Status changed from Feedback to Open

Gavin Fleming wrote:

no I tested as superuser on the same layer filtered to one record. The only difference was the QGIS version.

as I cannot replicate in any way i leave this open so others would be able to give it a try and leave feedback.

PS
If it affects master and it affects editing of PostGIS layers please leave the proper tags.

#7 Updated by Tim Sutton over 9 years ago

Giovanni Manghi wrote:

Gavin Fleming wrote:

no I tested as superuser on the same layer filtered to one record. The only difference was the QGIS version.

as I cannot replicate in any way i leave this open so others would be able to give it a try and leave feedback.

PS
If it affects master and it affects editing of PostGIS layers please leave the proper tags.

I was able to replicate here against Gavin's db. Under QGIS 2.6 the following simple expression fails to update existing field:

"type" + ')'

Under 2.4 this works:

"type" || ')'

#8 Updated by Gavin Fleming over 9 years ago

  • Category deleted (Data Provider/PostGIS)
  • Affected QGIS version changed from master to 2.6.0

#9 Updated by Tim Sutton over 9 years ago

I just tested using the python API:

l = iface.activeLayer()
exp = QgsExpression('"type" + \\')\\'')
f = l.getFeatures()
for feat in f:
    value = exp.evaluate(feat)
    print value

And that works fine, so the issue must lie in the caclulator itself.

#10 Updated by Giovanni Manghi over 9 years ago

I was able to replicate here against Gavin's db. Under QGIS 2.6 the following simple expression fails to update existing field:

[...]

Under 2.4 this works:

[...]

so it is just this particular expression (concatenation with the "+") that fails or any expression fails?

and then: it fails on any database or just one? and what about other formats?

I tested here on local and remote databases, with qgis 2.6 and master and both ways to do concatenation (|| and +) are working as expected from the field calculator.

#11 Updated by Gavin Fleming over 9 years ago

the concatenation is a red herring :-) - any expression fails. Remote vs local might be a red herring too.
2.4 works on shapefiles, postgresql 9.1 and postgresql 9.3
2.6 works on shpefiles, postgresql 9.3 but NOT postgresql 9.1

#12 Updated by Giovanni Manghi over 9 years ago

  • Status changed from Open to Feedback

2.6 works on shpefiles, postgresql 9.3 but NOT postgresql 9.1

I does not seems postgresql version either. I just installed postgresql 9.1/postgis 2 and tested with qgis 2.6 and all works as expected.

#13 Updated by Giovanni Manghi over 9 years ago

  • Category set to Field calculator

Tim Sutton wrote:

I just tested using the python API:

[...]

And that works fine, so the issue must lie in the caclulator itself.

is this #11538

the same issue?

#14 Updated by Gavin Fleming over 9 years ago

It does seem to be the same or related issue. I tested this one again and noticed the extra field that gets created as mentioned in #11538, which I hadn't noticed before.

#15 Updated by Wille Marcel over 9 years ago

I have the same issue. When I open the table of attributes, choose to just show the selected items and modify a field value using the toolbar of the table of attributes dialog, it works fine. But when I open the field calculator dialog and try to modify some values, it didn't apply the modifications.

Tim Sutton wrote:

I just tested using the python API:

[...]

And that works fine, so the issue must lie in the caclulator itself.

#16 Updated by Giovanni Manghi over 9 years ago

Wille Marcel wrote:

I have the same issue. When I open the table of attributes, choose to just show the selected items and modify a field value using the toolbar of the table of attributes dialog, it works fine. But when I open the field calculator dialog and try to modify some values, it didn't apply the modifications.

always? or just in same situation as #11538?

because for normally imported vectors then is works as expected...

#17 Updated by Wille Marcel over 9 years ago

Only with postgis. When editing vector files it works properly.

Giovanni Manghi wrote:

Wille Marcel wrote:

I have the same issue. When I open the table of attributes, choose to just show the selected items and modify a field value using the toolbar of the table of attributes dialog, it works fine. But when I open the field calculator dialog and try to modify some values, it didn't apply the modifications.

always? or just in same situation as #11538?

because for normally imported vectors then is works as expected...

#18 Updated by Giovanni Manghi over 9 years ago

Wille Marcel wrote:

Only with postgis.

yes, but the ticket I linked to you is about (and this one too) is about postgis tables (layers) created in a specific way. If you import a vector (shape, whatever) into postgis using qgis (db manager, browser. etc), shp2pgsql, ogr2ogr, etc. then this does not happens, or at least I can't confirm in any test I made so far.

#19 Updated by Wille Marcel over 9 years ago

I tried it in a OSM database created with osm2pgsql and in a database with all the vectors created using qgis. In both the error occurs.

Giovanni Manghi wrote:

Wille Marcel wrote:

Only with postgis.

yes, but the ticket I linked to you is about (and this one too) is about postgis tables (layers) created in a specific way. If you import a vector (shape, whatever) into postgis using qgis (db manager, browser. etc), shp2pgsql, ogr2ogr, etc. then this does not happens, or at least I can't confirm in any test I made so far.

#20 Updated by Giovanni Manghi over 9 years ago

Wille Marcel wrote:

I tried it in a OSM database created with osm2pgsql and in a database with all the vectors created using qgis. In both the error occurs.

can you attach a dump of one of the table that has the issue?

#21 Updated by Gavin Fleming about 9 years ago

appears to be fixed in master. The value updates in the table, detects that there are changes and saves, i.e. as expected. Database and PostGIS version and test data are the same as those that had this issue with 2.6 and earlier versions of master.

#22 Updated by Jürgen Fischer about 9 years ago

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

fixed in 32945058

Also available in: Atom PDF