qwc-services / qwc-data-service

QWC Data service
MIT License
5 stars 10 forks source link

White screen after inserting feature with id field hidden #25

Open smaspons opened 1 year ago

smaspons commented 1 year ago

Hi!

So I have a layer (postgresql view) that has a few fields and they all are filled by a trigger in database. In the QGIS project I have all the fields set to hidden so I can insert features without inputing any fields (the trigger handles them).

I'm trying to do this in QWC2 via the Editing plugin and I have a few problems:

Just so you know, I'm using the docker image: sourcepole/qwc-data-service:v2023.1-lts and the latest commit of qwc2 for the app.

Please, let me know if you need more details. Thanks!

manisandro commented 1 year ago

I can insert features but when I commit the screen goes white and it gives me an error like Uncaught TypeError: id is null

Can you post the full stack trace from the JS console (F12)? Make sure you are either running through a webpack dev server or a prod build with source-maps

When I go to select a feature to update it, it detects a lot of the neighbouring features, not just the one I clicked. I don't know if it's intended or it's a bug or something I'm doing wrong, but it seems to me that the Editing plugin doesn't manage the zoom level properly

Features are queried with a 10px tolerance, see https://github.com/qgis/qwc2/blob/master/utils/EditingInterface.js#L60

Also, if the id is hidden, the combobox with all the features that it found is full of empty strings, although they are properly managed as I can see the highlight on the map.

You should set the display field (QGIS -> layer properties -> display -> display name) to a non-hidden field

If I try to update a feature (its geometry) it gives me the error ERROR: source for a multiple-column UPDATE item must be a sub-SELECT or ROW() expression , which I'm guessing is solved with the last commit.

Please use the lastest qwc-data-service (v2023.10.12)

smaspons commented 1 year ago

Can you post the full stack trace from the JS console (F12)? Make sure you are either running through a webpack dev server or a prod build with source-maps

Yes! There are multiple errors, all of them occur when I commit the feature: console-export-2023-10-13_12-59-59.txt Btw, it inserts the feature correctly, the issue is after inserting it i guess...

Features are queried with a 10px tolerance

Hmm, I'll look more into it, because no matter where I click it finds all the features

manisandro commented 1 year ago

I take the id is null of the GeoJSON feature returned by the data service after insert?

smaspons commented 1 year ago

Yes, the id is null, but the geometry is correct I think

manisandro commented 1 year ago

My guess is that since you are using a view, and a view cannot have a primary key, the data-service won't be able to return an id for the feature (hence null) and hence everything else falls down as well.

In short, editing on views is currently unsupported.

smaspons commented 1 year ago

Okay, I understand. Well, I'll see what I can do to work around this.

Thanks anyway for the quick responses!

tpo commented 1 year ago

My guess is that since you are using a view, and a view cannot have a primary key, the data-service won't be able to return an id for the feature (hence null) and hence everything else falls down as well.

In short, editing on views is currently unsupported.

@mwa @HusseinKabbout - we have been recently discussing this AFAI remember. You might want to shortcircuit with @manisandro ... !

cymed commented 1 month ago

@smaspons As you are working on postgres, you might try defining a default value on the view

ALTER VIEW my_schema.vw_foobar
    ALTER COLUMN pseudo_pkey SET DEFAULT nextval('my_schema.pkey_seq'::regclass)