Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Update operation for WFS layers without geometry #60185

Closed
2 tasks done
gisuser0 opened this issue Jan 20, 2025 · 7 comments · Fixed by #60266
Closed
2 tasks done

Missing Update operation for WFS layers without geometry #60185

gisuser0 opened this issue Jan 20, 2025 · 7 comments · Fixed by #60266
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Server Related to QGIS server

Comments

@gisuser0
Copy link

gisuser0 commented Jan 20, 2025

What is the bug or the crash?

Only Query, Insert and Delete are allowed for WFS layers without geometry. The Update operation is not available.

Steps to reproduce the issue

  1. load any table without geometry into a QGIS project and enable all the WFS capabilities: Insert, Update and Delete (Project -> Properties -> QGIS Server -> WFS/OAPIF tab)
  2. publish the project with QGIS-Server
  3. Query, Insert and Delete are listed in the Operations of the WFS getCapabilities but Update is missing
  4. open the layer with a WFS client (e.g. QGIS Desktop) and try to edit it: you can query, create and delete features but you can't update them

Versions

3.34.14 LTR (Windows and Linux)
3.40.2 (Windows and Linux)

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

Looking into the code it seems like the Update operation always requires the change geometry capability (Qgis::VectorProviderCapability::ChangeGeometries)

@gisuser0 gisuser0 added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Jan 20, 2025
@agiudiceandrea agiudiceandrea added the Server Related to QGIS server label Jan 20, 2025
@elpaso elpaso self-assigned this Jan 23, 2025
@elpaso
Copy link
Contributor

elpaso commented Jan 23, 2025

I cannot reproduce and I think I need more details about the aspatial layer you are testing with (can you attach a small/minimal sample?)

@elpaso elpaso added the Feedback Waiting on the submitter for answers label Jan 23, 2025
@gisuser0
Copy link
Author

gisuser0 commented Jan 24, 2025

Steps to reproduce the issue:

  1. Create a PostgreSQL/PostGIS database
    CREATE DATABASE testwfs;

  2. Connect to the database and create one table with geometries and one table without geometries:
    CREATE EXTENSION IF NOT EXISTS postgis;
    CREATE TABLE with_geom (id serial, geom geography(POINT,4326), description character varying, CONSTRAINT with_geom_pkey PRIMARY KEY (id));
    CREATE TABLE without_geom (id serial, description character varying, CONSTRAINT without_geom_pkey PRIMARY KEY (id));

  3. Create a feature with geometry and a feature without geometry:
    INSERT INTO with_geom (geom, description) VALUES('SRID=4326;POINT(0 0)', 'With geometry');
    INSERT INTO without_geom (description) VALUES('Without geometry');

  4. Open an empty QGIS project, connect to the database and import the two tables (check "Also list tables with no geometry" in the connection properties in order to view also the without_geom table)

  5. Enable all the WFS capabilities for both the layers (Project -> Properties -> QGIS Server -> WFS/OAPIF tab: check Published, Update, Insert and Delete)

  6. Publish the project with QGIS-Server

  7. Call the WFS getCapabilities. The with_geom layer has the Update operation while the without_geom layer doesn't have the Update operation

with_geom

<Name>with_geom</Name>
<Title>with_geom</Title>
<DefaultSRS>EPSG:4326</DefaultSRS>
<OtherSRS>EPSG:3857</OtherSRS>
<Operations>
<Operation>Query</Operation>
<Operation>Insert</Operation>
<Operation>Update</Operation>
<Operation>Delete</Operation>
</Operations>

without_geom

<Name>without_geom</Name>
<Title>without_geom</Title>
<DefaultSRS/>
<OtherSRS>EPSG:4326</OtherSRS>
<OtherSRS>EPSG:3857</OtherSRS>
<Operations>
<Operation>Query</Operation>
<Operation>Insert</Operation>
<Operation>Delete</Operation>
</Operations>
  1. connect to the WFS service with QGIS Desktop and try to change the description field in both the layers: the field in the with_geom table is editable while the field in the without_geom is not editable

@elpaso elpaso removed the Feedback Waiting on the submitter for answers label Jan 24, 2025
elpaso added a commit to elpaso/QGIS that referenced this issue Jan 24, 2025
@elpaso
Copy link
Contributor

elpaso commented Jan 24, 2025

@gisuser0 for the record, the fact that you were using postgres was the missing information to be able to reproduce the issue.

@gisuser0
Copy link
Author

Thx for the fix

@gisuser0
Copy link
Author

gisuser0 commented Jan 25, 2025

It seems like the missing check isSpatial() also for the wfs transaction block the update.

qgswfstransaction.cpp

Qgis::VectorProviderCapabilities cap = provider->capabilities();
      if ( !( cap & Qgis::VectorProviderCapability::ChangeAttributeValues ) || !( cap & Qgis::VectorProviderCapability::ChangeGeometries ) )
      {
        action.error = true;
        action.errorMsg = QStringLiteral( "No capabilities to do WFS updates on layer '%1'" ).arg( typeName );
        continue;
      }
      // start editing
      vlayer->startEditing();

Should this solve it?

Qgis::VectorProviderCapabilities cap = provider->capabilities();
      if ( 
            !( cap & Qgis::VectorProviderCapability::ChangeAttributeValues ) || 
             (vlayer->isSpatial() && !(cap & Qgis::VectorProviderCapability::ChangeGeometries ) )
         )
      {
        action.error = true;
        action.errorMsg = QStringLiteral( "No capabilities to do WFS updates on layer '%1'" ).arg( typeName );
        continue;
      }
      // start editing
      vlayer->startEditing();

@elpaso
Copy link
Contributor

elpaso commented Jan 25, 2025

@gisuser0 yes: that needs the same changes, I am sorry: I only checked the getcapabilities and I assumed the transaction part was ok. I will make another PR for that.

elpaso added a commit to elpaso/QGIS that referenced this issue Jan 25, 2025
Not a critical change but more precise check in case of
aspatial layers.

Followup qgis#60266
Related to qgis#60185
@elpaso
Copy link
Contributor

elpaso commented Jan 25, 2025

@gisuser0 this should fix the last issue: #60273

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Server Related to QGIS server
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants