[Qgis-user] Editing attributes in embedded forms

Bo Victor Thomsen bo.victor.thomsen at gmail.com
Thu Jun 3 01:07:21 PDT 2021


Hi Pekka -

I think you ran into a QGIS - Postgres problem using the "identity" type 
qualifier.

I tried to execute your "create table" example with the "Identity" type 
definition for the primary key. It doesn't create the sequence that QGIS 
assumes exist.

Changing you sample code to:

     CREATE TABLE IF NOT EXISTS data.sample_point2
     (
         fid serial NOT NULL,
         wkb_point geometry(Point,3067),
         name varchar,
         CONSTRAINT sample_point2_pk PRIMARY KEY (fid)
     );

i.e change the PK column to a "serial" will produce the expected 
sequence in Postgres. The last table will probably function correctly in 
QGIS  (Not tested, and yes - I know: Identity and Serial types is not 
the same)


Med venlig hilsen / Kind regards

Bo Victor Thomsen

Den 03-06-2021 kl. 08:23 skrev Pekka Sarkola:
> Hi,
> You repeat this "ERROR: column "sample_point_fid_seq" does not exist" 
> -problem with:
> Create very simple table to PostGIS (choose your own CRS):
>
>     CREATE TABLE IF NOT EXISTS sample_point
>     (
>         fid integer NOT NULL GENERATED ALWAYS AS IDENTITY,
>         wkb_point geometry(Point,3067),
>         name varchar,
>         CONSTRAINT sample_point_pk PRIMARY KEY (fid)
>     );
>
> Add table to QGIS. Editing works, without errors.
>
> If you tick on from project properties: "Evaluate default values on 
> provider side", error will happen:
>
>     2021-06-03T09:22:31     WARNING Erroneous query: SELECT
>     nextval("sample_point_fid_seq"::regclass) returned 7 [ERROR:
>     column "sample_point_fid_seq" does not exist
>
>                  LINE 1: SELECT nextval("sample_point_fid_seq"::regclass)
>
>                   ^
>
>                  ]
>
> Rgs,
>
> Pekka
>
> Pekka Sarkola
> Gispo Oy
> pekka.sarkola at gispo.fi <mailto:pekka.sarkola at gispo.fi>   - GSM +358 
> 40 725 2042
> www.gispo.fi <http://www.gispo.fi/>– www.paikkatieto.com 
> <http://www.paikkatieto.com/>
>
>
>
> to 3. kesäk. 2021 klo 8.47 Pekka Sarkola (pekka at gispo.fi 
> <mailto:pekka at gispo.fi>) kirjoitti:
>
>     Hi Alexandre et al,
>
>     I re-create a database (sample one), create a new QGIS project,
>     add layers => same error. Maybe I open an issue in Github and I
>     can share more SQL and snapshots.
>
>     Rgs,
>
>     Pekka
>
>     Pekka Sarkola
>     Gispo Oy
>     pekka.sarkola at gispo.fi <mailto:pekka.sarkola at gispo.fi>   - GSM
>     +358 40 725 2042
>     www.gispo.fi <http://www.gispo.fi/>– www.paikkatieto.com
>     <http://www.paikkatieto.com/>
>
>
>
>     ti 1. kesäk. 2021 klo 16.36 Alexandre Neto (senhor.neto at gmail.com
>     <mailto:senhor.neto at gmail.com>) kirjoitti:
>
>         From that last error...
>
>         Are you sure your table was not changed after being loaded to
>         QGIS? It seems to expect a sequence that no longer exists.
>
>         Alexandre Neto
>
>         A terça, 1/06/2021, 12:22, Pekka Sarkola <pekka at gispo.fi
>         <mailto:pekka at gispo.fi>> escreveu:
>
>             Hi Andreas,
>
>             Trasnsactions groups are enabled: editing is working (not
>             in embedded forms) as expected.
>
>             If I enable "Evaluate default values.."-option, I will get
>             error:
>
>             2021-06-01T14:11:44     WARNING  Erroneous query: SELECT
>             nextval("sample_point_fid_seq"::regclass) returned 7
>             [ERROR: column "sample_point_fid_seq" does not exist
>                          LINE 1: SELECT
>             nextval("sample_point_fid_seq"::regclass)
>
>             Primary key of the geometry table is "fid" and it has been
>             defined as IDENTITY column (fid integer NOT NULL GENERATED
>             ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1
>             MAXVALUE 2147483647 CACHE 1 ).
>
>             I presume this evaluation of the default values is not the
>             solution for this case.
>
>             Rgs,
>
>             Pekka
>
>             Pekka Sarkola
>             Gispo Oy
>             pekka.sarkola at gispo.fi <mailto:pekka.sarkola at gispo.fi>-
>             GSM +358 40 725 2042
>             www.gispo.fi <http://www.gispo.fi/>– www.paikkatieto.com
>             <http://www.paikkatieto.com/>
>
>
>
>             ti 1. kesäk. 2021 klo 11.10 Andreas Neumann
>             (a.neumann at carto.net <mailto:a.neumann at carto.net>) kirjoitti:
>
>                 Hi Pekka,
>
>                 Have you enabled the  transaction mode in your project?
>
>                 See menu "Project" --> "Properties" --> "Data Sources".
>
>                 I usually enable all three check boxes:
>
>                 - Automatically create transaction groups where possible
>
>                 - Evaluate default values on provider side
>
>                 - Trust project when data source has no metadata
>
>                 The transaction mode allows to edit all layers from
>                 the same data base connection (needs identical db
>                 connection string and credentials) and - together with
>                 "evaluate default values on provider side" -
>                 immediately retrieves primary keys from the DB, so
>                 that you can link objects immediately, without having
>                 to save first.
>
>                 Greetings,
>
>                 Andreas
>
>                 On 2021-06-01 09:55, Pekka Sarkola wrote:
>
>>                 Hi folks!
>>                 I have a problem editing feature attributes in
>>                 embedded forms. Data is stored in PostGIS and I have
>>                 a simple 1:1 relationship with the geometry table and
>>                 an additional attribute table. QGIS version is 3.18.3
>>                 on Ubuntu.
>>                 I have created a custom form with a drag-and-drop
>>                 designer. I can edit additional attribute table
>>                 attributes in embedded form, but those edits are not
>>                 stored anywhere. I have to open a separate form and
>>                 then edit attribute values of the related attribute
>>                 table. This is quite annoying for the end user.
>>                 Any suggestions? Or should I write a better
>>                 description to the Github?
>>                 Rgs,
>>                 Pekka
>>
>>                 Pekka Sarkola
>>                 Gispo Oy
>>                 pekka.sarkola at gispo.fi
>>                 <mailto:pekka.sarkola at gispo.fi>- GSM +358 40 725 2042
>>                 www.gispo.fi <http://www.gispo.fi/>–
>>                 www.paikkatieto.com <http://www.paikkatieto.com/>
>>
>>
>>                 _______________________________________________
>>                 Qgis-user mailing list
>>                 Qgis-user at lists.osgeo.org
>>                 <mailto:Qgis-user at lists.osgeo.org>
>>                 List info:
>>                 https://lists.osgeo.org/mailman/listinfo/qgis-user
>>                 <https://lists.osgeo.org/mailman/listinfo/qgis-user>
>>                 Unsubscribe:
>>                 https://lists.osgeo.org/mailman/listinfo/qgis-user
>>                 <https://lists.osgeo.org/mailman/listinfo/qgis-user>
>
>
>             _______________________________________________
>             Qgis-user mailing list
>             Qgis-user at lists.osgeo.org <mailto:Qgis-user at lists.osgeo.org>
>             List info:
>             https://lists.osgeo.org/mailman/listinfo/qgis-user
>             <https://lists.osgeo.org/mailman/listinfo/qgis-user>
>             Unsubscribe:
>             https://lists.osgeo.org/mailman/listinfo/qgis-user
>             <https://lists.osgeo.org/mailman/listinfo/qgis-user>
>
>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20210603/b2e1a8c8/attachment-0001.html>


More information about the Qgis-user mailing list