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

White screen after inserting feature with id field hidden #25

Open
smaspons opened this issue Oct 13, 2023 · 8 comments
Open

White screen after inserting feature with id field hidden #25

smaspons opened this issue Oct 13, 2023 · 8 comments

Comments

@smaspons
Copy link

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:

  • I can insert features but when I commit the screen goes white and it gives me an error like Uncaught TypeError: id is null
  • 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.
  • 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.
  • 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.

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
Copy link
Member

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
Copy link
Author

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
Copy link
Member

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

@smaspons
Copy link
Author

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

@manisandro
Copy link
Member

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
Copy link
Author

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

Thanks anyway for the quick responses!

@tpo
Copy link
Member

tpo commented Oct 13, 2023

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
Copy link

cymed commented Sep 20, 2024

@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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants