lizmap-web-client icon indicating copy to clipboard operation
lizmap-web-client copied to clipboard

Problem editing table with no geometry using the Edition Tool

Open geographit opened this issue 3 years ago • 6 comments

What is the bug?

Hi,

I have a bug when trying to edit a table without geometry. The edition tool hangs and doesn't show the editing panel.

The browser developer mode displays the following error: Failed to load resource: the server responded with a status of 500 (Internal Jelix Error)

It similar to the following issue : https://github.com/3liz/lizmap-web-client/issues/1973

Steps to reproduce the issue

  1. Add a layer without geometry 2.Publish WFS 3.Allow edition to layer check (Create, Delete, Modify and Allow no geometry) 4.Allow to show attribute table of the layer 5.Go to Lizmap Web Client 6.Edit -> Select the layer -> Add 7.It only charges, no form is display

Expected behavior

Get a form to edit the table.

Environment

  • Lizmap version: 3.4.2 and 3.4.3
  • QGIS Server FULL version: 3.16
  • QGIS Desktop FULL version: 3.16.1
  • OS (Windows, Linux, MacOS, Android…): Ubuntu 20
  • Browser (Firefox, Chrome…): Brave
  • Lizmap admin information (users, logs…) stored intoPostgreSQL

geographit avatar Apr 04 '21 01:04 geographit

It seems the issue is not always consistent. The issue persist when creating a project with QGIS desktop 3.12 - 3.16.5

I get the following error in lizmap error.log : error 2021-04-04 19:14:34 [0] dbtools, pgsql: unknown table /lib/jelix/plugins/db/pgsql/pgsql.dbtools.php 242

Creating a project with Qgis desktop 3.8 does seem to fix the problem.

geographit avatar Apr 04 '21 16:04 geographit

Hi, we have the same problem: endless loading editing tool for postgres layer with no geometry. Also, same message in lizmap error log.

We saved the Qgis project with Qgis desktop 3.8 as suggested (thank you so much @geographit) to get around the problem. Finally, we tried to compare layer definition between the .qgs files, but we noticed nothing relevant. See below for further details.

Here layer definition in Qgis Desktop 3.16: <layer-tree-layer expanded="1" legend_split_behavior="0" id="r_conpub_anagditte_0785406e_ab2a_47c5_850d_70a32c38a65d" legend_exp="" checked="Qt::Checked" providerKey="postgres" name="r_conpub_anagditte" source="dbname='nuovo_cs' host=10.1.1.123 port=5432 user='catasto_strade_editor' sslmode=disable key='id' estimatedmetadata=true checkPrimaryKeyUnicity='1' table=&quot;eventop&quot;.&quot;r_conpub_anagditte&quot;" patch_size="-1,-1"> <customproperties> <property key="embedded" value="1"/> <property key="embedded_project" value="./catasto_strade.qgs"/> </customproperties> </layer-tree-layer>

Here, the same layer in Qgis Desktop 3.8 : <layer-tree-layer source="dbname='nuovo_cs' host=10.1.1.123 port=5432 user='catasto_strade_editor' sslmode=disable key='id' checkPrimaryKeyUnicity='1' table=&quot;eventop&quot;.&quot;r_conpub_anagditte&quot; sql=" id="r_conpub_anagditte_dda376bc_ef23_425a_8393_d52b0161cd08" name="r_conpub_anagditte2" providerKey="postgres" checked="Qt::Checked" expanded="1"> <customproperties/> </layer-tree-layer>

amrossx avatar Apr 12 '21 15:04 amrossx

I think maybe jelix is having some issues parsing .qgs files generated with Qgis desktop 3.16?

geographit avatar Apr 13 '21 15:04 geographit

I'm having same issue (loading bar stuck in editing mode) using LWC v. 3.4.3, both Qgis Desktop & Server v. 3.16.5, lizmap server plugin v. 3.4.4 I'll try with Qgis Desktop v.3.8 as suggested and let you know....

@edit: I've tried and I can confirm everything works well with Qgis Desktop 3.8.3 (same project .qgs not working if saved with Qgis desktop v3.16.5 LTR or 3.14.x, It is working if saved in 3.8.x version).

@edit2: I confirm editing tables with no geometry works even with a .qgs project saved with QGIS Destktop v3.10.14 LTR

ocelot73 avatar Apr 15 '21 13:04 ocelot73

hi everyone, just to confirm that the issue with editing table without geometry is still occurring. Without knowing about it i had upgraded the QGIS LTR version from 3.10 to 3.16 and the editing tool (for no geometry tables) stopped working. I had to return to the old QGIS LTR. By the way, my current working environment is the same @ocelot73 [ LWC v. 3.4.3, both Qgis Desktop & Server v. 3.16.5, lizmap server plugin v. 3.4.4] and the desktop has Ubuntu 18.04 OS.

InnovPlantProtect avatar Jun 15 '21 14:06 InnovPlantProtect

hi everybody, just to confirm we have the same issue with editing table without geometry (loading bar stuck in editing mode). Environment: Qgis 3.16 both on server and desktop , Lizmap 3.4.3, Debian server and Chrome browser on Windows. As soon as possible we'll try to save the project with Qgis desktop LTR 3.10.

tethysgeco avatar Oct 14 '21 08:10 tethysgeco

Is this issue still valid ?

We have some automatic tests with tables without geometry. it's working for test case.

Gustry avatar Jul 18 '23 17:07 Gustry

@Gustryin my configuration,

Schermata del 2023-07-19 11-42-03

I just try with a table on my project, the editing it seems to works but, when I try to insert a new record in my table, with the three values required from my fields, and hit for store it in my table, only ID field It's populed. I attach three screenshots

  1. Editing of a table without geometry by LWC Schermata del 2023-07-19 11-30-22

  2. record effectively stored on postgres table

Schermata del 2023-07-19 11-31-25

probably It's a new bug but as is how it works

  1. my settings for editing of the table

Schermata del 2023-07-19 11-39-16

Antoviscomi avatar Jul 19 '23 09:07 Antoviscomi

Ok, strange, a new bug and not the correct title anymore ? can you provide the SQL definition of your layer ? Maybe your QGIS widget for one of the field too ? Did you look if you have any log on your LWC admin panel ? On your PG server, the SQL request hitting the server ?

Gustry avatar Jul 19 '23 10:07 Gustry

@Gustry here is the LWC log

2023-07-19 11:28:37	160.97.53.182	error	An error has been raised when saving form data edition to db : 
2023-07-19 11:28:37	160.97.53.182	[403]	query non valida (ERRORE:  un valore chiave duplicato viola il vincolo univoco "CE_15-21_Granulometria_2_pkey"
DETAIL:  La chiave (id)=(9999) esiste già.( INSERT INTO "public"."CE_15-21_Granulometria_2" ("id" ) VALUES (9999 )  RETURNING "id";))	/var/www/lizmap/lizmap/vendor/jelix/jelix/lib/jelix/plugins/db/pgsql/pgsql.dbconnection.php	210
	/webgis/index.php/lizmap/edition/saveFeature
array (   'module' => 'lizmap',   'action' => 'edition:saveFeature',   'liz_project' => 'Cetraro',   'liz_repository' => 'cetraro',   'liz_layerId' => 'CE_15_21_Granulometria_2_8af4549b_1de0_4759_99d1_826084932083',   'liz_featureId' => '',   'liz_srid' => '0',   'liz_proj4' => '',   'liz_geometryColumn' => '',   'liz_status' => '0',   '_submit' => 'submit',   '__JFORMS_TOKEN__' => 'cfc2a3fedb6f484a0430ba0f286fb6ed7cfe6534',   'id' => '9999',   'Diametro_(mm)' => '111',   'Passante_(%)' => '1',   'liz_future_action' => 'close', )

Antoviscomi avatar Jul 19 '23 10:07 Antoviscomi

and this is the SQL definition

-- Table: public.CE_15-21_Granulometria_2

-- DROP TABLE IF EXISTS public."CE_15-21_Granulometria_2";

CREATE TABLE IF NOT EXISTS public."CE_15-21_Granulometria_2"
(
    id integer NOT NULL,
    "Diametro (mm)" double precision,
    "Passante (%)" double precision,
    CONSTRAINT "CE_15-21_Granulometria_2_pkey" PRIMARY KEY (id)
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public."CE_15-21_Granulometria_2"
    OWNER to postgres;

Antoviscomi avatar Jul 19 '23 10:07 Antoviscomi

and here is what my PG server receive

2023-07-19 11:28:37.349 CEST [5331] postgres@myraster1 ISTRUZIONE:   INSERT INTO "public"."CE_15-21_Granulometria_2" ("id" ) VALUES (9999 )  RETURNING "id";

Antoviscomi avatar Jul 19 '23 10:07 Antoviscomi

I don't understand what you mean for "only a field" (enabled for editing I suppose), in QGIS widget, I doesn't know there's a way to set which field can be edited, however here are the QGIS widget settings for the layer Schermata del 2023-07-19 12-44-51

Antoviscomi avatar Jul 19 '23 10:07 Antoviscomi

@Gustry here is the LWC log 2023-07-19 11:28:37 160.97.53.182 error An error has been raised when saving form data edition to db : 2023-07-19 11:28:37 160.97.53.182 [403] query non valida (ERRORE: un valore chiave duplicato viola il vincolo univoco "CE_15-21_Granulometria_2_pkey" DETAIL: La chiave (id)=(9999) esiste già.( INSERT INTO "public"."CE_15-21_Granulometria_2" ("id" ) VALUES (9999 ) RETURNING "id";)) /var/www/lizmap/lizmap/vendor/jelix/jelix/lib/jelix/plugins/db/pgsql/pgsql.dbconnection.php 210

this was because of I tried to reinsert the values without drop the previous stored record, so, isn't a a real LWC error (but mine)

Antoviscomi avatar Jul 19 '23 10:07 Antoviscomi

@Gustry I find what went wrong, the special character on field names, I renamed the two field as Passante and Diametro, and all works fine. many thanks, I think you can close this topic

Antoviscomi avatar Jul 19 '23 10:07 Antoviscomi

however here are the QGIS widget settings for the layer

Well I mean clicking on a field and to show us the configuration on the right panel, the one you are not showing us on your screenshot.

The error message in https://github.com/3liz/lizmap-web-client/issues/2228#issuecomment-1641816448 is explicit ... It helps reading logs in the backend to see what is happening ;-) Make your field autoincremented and hidden from the user to not let him edit it. It will solve your issue.

I doesn't know there's a way to set which field can be edited,

Use the Drag Drop layout and remove your field from the form if needed.

https://github.com/3liz/lizmap-web-client/issues/2228#issuecomment-1641817775 Adding some SQL coloring syntax in github helps ;-)

Gustry avatar Jul 19 '23 11:07 Gustry

And Passante (%) is a bad idea for naming a field. Use machine name, no space, or accents or special charcaters etc.

Instead use field alias in QGIS to customize the way the field is displayed for the human.

Gustry avatar Jul 19 '23 11:07 Gustry

Hi, from our side, the issue seems solved with newer versions.

tethysgeco avatar Jul 19 '23 12:07 tethysgeco