Bug report #6120
Field calculator doesn't disable field addition, when layer doesn't have the capability
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | GUI | ||
Affected QGIS version: | master | Regression?: | No |
Operating System: | Easy fix?: | No | |
Pull Request or Patch supplied: | No | Resolution: | |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 15459 |
Description
I'm not sure this will be seen as a bug from the dev point of view, but it is certainly and inconsistency from the users point of view.
It happens that if a PostGIS user has the proper permissions but it is not the table owner, can edit geometries and attributes (from within the table of attributes), but cannot edit attributes with the field calculator.
I guess that the obvious reason is that the FC does "alter table" operations that are allowed only to table owners.
A suggestion that has been made is to create the new column (or update the existing column) into a new view instead of the original table.
Related issues
Associated revisions
History
#1 Updated by Jürgen Fischer over 12 years ago
- Status changed from Open to Feedback
You mean the user can change attributes in the attribute table, but cannot update existing fields using the field calculator? That would be a bug.
If the user just can't add fields via the field calculator, the attribute table or the layer properties, because he lacks the required database permissions to do that, that's not a bug.
#2 Updated by Giovanni Manghi over 12 years ago
Jürgen Fischer wrote:
You mean the user can change attributes in the attribute table, but cannot update existing fields using the field calculator? That would be a bug.
If the user just can't add fields via the field calculator, the attribute table or the layer properties, because he lacks the required database permissions to do that, that's not a bug.
Hi Jürgen,
the answer to both questions is "yes". In particular:
- I gave the non owner user GRANT USAGE ON schema
- I gave the non owner user GRANT ALL geometry_columns
- I gave the non owner user GRANT SELECT ON spatial_ref_sys
- I gave the non owner user GRANT ALL ON table
The user as expected can't add/delete fields (from the table of attributes, vector properties or field calculator) but CAN edit/add/delete geometries and attributes (from the table of attributes).
As not expected the user can't update an existing field using the field calculator, as the "ok" button remains always deactivated.
Moreover the "create new field" (in the field calculator) refers correctly "(not supported by provider)" but the checkbox remains active as also the "out field name" and "output field type" puzzling even more the user.
#3 Updated by Jürgen Fischer over 12 years ago
- Subject changed from Field calculator cannot be used if a PostGIS user is not table owner to Field calculator doesn't disable field addition, when layer doesn't have the capability
#4 Updated by Jürgen Fischer over 12 years ago
- Category changed from Data Provider/PostGIS to GUI
#5 Updated by Giovanni Manghi over 12 years ago
Hi Jurgen,
I'm not sure the new title reflects correctly the issue that non owner users are not allowed to update fields wiht the FC.
#6 Updated by Jürgen Fischer over 12 years ago
Giovanni Manghi wrote:
I'm not sure the new title reflects correctly the issue that non owner users are not allowed to update fields wiht the FC.
The field calculator doesn't know anything about specific providers. Providers have the optional capability to add attributes. And if I understood correctly the field calculator fails to disable UI options that required AddAttributes
accordingly, if the provider (or in this case the layer) doesn't have that capability.
#7 Updated by Giovanni Manghi over 12 years ago
Jürgen Fischer wrote:
Giovanni Manghi wrote:
I'm not sure the new title reflects correctly the issue that non owner users are not allowed to update fields wiht the FC.
The field calculator doesn't know anything about specific providers. Providers have the optional capability to add attributes. And if I understood correctly the field calculator fails to disable UI options that required
AddAttributes
accordingly, if the provider (or in this case the layer) doesn't have that capability.
I'm not sure I am following you.
There are two separate issues, as far I have I understand (and you know I may be wrong, so excuse me if it is the case):
the important issue is that a non owner user, with the proper permissions, should still be able to update fields with the FC.
the less important issue (but still and issue) is that in same situation the GUI of FC (to allow choose options to create a new field) should be disabled.
This ticket was filed about the first issue, later I added a note also about the second one.
#8 Updated by Jürgen Fischer over 12 years ago
Giovanni Manghi wrote:
the important issue is that a non owner user, with the proper permissions, should still be able to update fields with the FC.
That's outside of the scope of the field calculator. If the provider reports that the layer supports ChangeAttributeValues
the field calculator should be able to update the field values, if it doesn't the field calculator should not enable that option.
The option to add a new field should only be enabled, if the providers reports the AddAttributes
capability.
So if the field calculator doesn't react on the capabililies accordingly it's a bug in the field calculator.
If the provider doesn't report the proper capabilities (see layer properties) it's a bug in the provider.
#9 Updated by Giovanni Manghi over 12 years ago
That's outside of the scope of the field calculator. If the provider reports that the layer supports
ChangeAttributeValues
the field calculator should be able to update the field values, if it doesn't the field calculator should not enable that option.
so it is a provider issue, right? As you changed the title of this ticket, should I file a new ticket?
The option to add a new field should only be enabled, if the providers reports the
AddAttributes
capability.
ok, this was already clear, in fact if you read above my comments I already told that this was working as expected. The non owner user can't add/remove fields and it is ok.
So if the field calculator doesn't react on the capabililies accordingly it's a bug in the field calculator.
If the provider doesn't report the proper capabilities (see layer properties) it's a bug in the provider.
See above my comments: the NON owner user CAN add/delete/edit features in the canvas or in the table of attributes but CAN'T update a field in the FC (the "OK" button is disabled). But as a mere user I can't say if it is a bug in the provider or in the FC.
#10 Updated by Giovanni Manghi over 12 years ago
Jürgen Fischer wrote:
Giovanni Manghi wrote:
the important issue is that a non owner user, with the proper permissions, should still be able to update fields with the FC.
That's outside of the scope of the field calculator. If the provider reports that the layer supports
ChangeAttributeValues
the field calculator should be able to update the field values, if it doesn't the field calculator should not enable that option.The option to add a new field should only be enabled, if the providers reports the
AddAttributes
capability.So if the field calculator doesn't react on the capabililies accordingly it's a bug in the field calculator.
If the provider doesn't report the proper capabilities (see layer properties) it's a bug in the provider.
Hi Jürgen please let me know if/what I have to do (file a new ticket or not, and eventually the right category), because I'm a little confused right now. Thanks in advance.
#11 Updated by Jürgen Fischer over 12 years ago
Giovanni Manghi wrote:
But as a mere user I can't say if it is a bug in the provider or in the FC.
Why? The capabilities are listed in the layer properties meta data tab. With that and the comments above it should be possible - even for mere testing team leads and long-term users ;) - to determine if the reported capabilities are wrong or the field calculators interpretation of it.
#12 Updated by Jürgen Fischer over 12 years ago
- Status changed from Feedback to Closed
Fixed in changeset 28b8ab09add47914ebd2c678baf769160d65ee37.
#13 Updated by Giovanni Manghi over 12 years ago
Why? The capabilities are listed in the layer properties meta data tab. With that and the comments above it should be possible - even for mere testing team leads and long-term users ;) - to determine if the reported capabilities are wrong or the field calculators interpretation of it.
So, this is what metadata shows for a layer loaded with a non owner users, with permissions to edit the table
General:
Storage type of this layer: PostgreSQL database with PostGIS extension
Source for this layer: dbname='persist' host=mapserver.uevora.pt port=5432 user='persist' sslmode=disable key='id' srid=3763 type=POLYGON table="lena_maio2012"."area_armadilhagem" (geom) sql=
Geometry type of the features in this layer: Polygon
The number of features in this layer: 1
Editing capabilities of this layer: Add Features, Delete Features, Change Attribute Values, Fast Access to Features at ID, Change Geometries
Extents:
In layer spatial reference system units : xMin,yMin -54926,-212755.94 : xMax,yMax -53926,-211755.95
Layer Spatial Reference System:
+proj=tmerc +lat_0=39.66825833333333 +lon_0=-8.133108333333334 +k=1 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
and as expected the user can edit geometries and attributes from the table of attributes, but cannot update a field with the FC (ad expected, or am I wrong?). Your commit fixes this, right?
#14 Updated by Jürgen Fischer over 12 years ago
Giovanni Manghi wrote:
Editing capabilities of this layer: Add Features, Delete Features, Change Attribute Values, Fast Access to Features at ID, Change Geometries
See: no "Add Attributes"
and as expected the user can edit geometries and attributes from the table of attributes, but cannot update a field with the FC (ad expected, or am I wrong?). Your commit fixes this, right?
Right, on layers without "Add Attributes" the field calculator was disabling both and not just adding of new fields.