[QGIS-Developer] Question on @atlas_featureid

Matthias Kuhn matthias at opengis.ch
Sun Jul 11 22:59:58 PDT 2021


Hi

It depends on the implementation in the data provider (and normally on the
data type for the primary key).

In the postgres case, (up to) 32 bit integer primary keys are normally used
as fid.
With others like 64 bit integer, string or compound foreign keys it's not
possible to stick to this approach, so an internal fid to pk map is
generated by the provider at runtime.

64 bit integers cannot be directly reused as fid because QGIS stores fids
internally with 64 bit, but reserves the (negative, -1, -2, ...) half of
the available values for new, uncommitted features.

Matthias


On Thu, Jul 8, 2021 at 11:50 AM Andreas Neumann <andreas at qgis.org> wrote:

> Ok - that explains it.
>
> It is quite confusing that QGIS uses a different internal ID than the
> primary key column of the database. Is there a technical reason for this
> behaviour?
>
> Andreas
>
>
>
> On Thu, 8 Jul 2021 at 11:43, Alexandre Neto <senhor.neto at gmail.com> wrote:
>
>> As far as I remember @atlas_featureid has always returned the same as the
>> $id in the attributes table, which is kind of the internal row number.
>>
>> Alex
>>
>> A quinta, 8/07/2021, 10:35, Andreas Neumann <andreas at qgis.org> escreveu:
>>
>>> HI Jürgen,
>>>
>>> Yes - I provided the primary key column
>>>
>>> Here is my data source string:
>>>
>>> service='edit' authcfg=sogis00 key='t_id' srid=2056 type=Polygon
>>> checkPrimaryKeyUnicity='1'
>>> table="alw_strukturverbesserungen"."projekt_aggregiert_v"
>>> (geometrie_convex_hull) sql=geometrie_bbox IS NOT NULL
>>>
>>> @atlas_featureid returns something like an internal "row number" or
>>> similar, but not the column "t_id" as defined in the data source string.
>>>
>>> Andreas
>>>
>>> On Thu, 8 Jul 2021 at 10:42, Jürgen E. Fischer <jef at norbit.de> wrote:
>>>
>>>> Hi Andreas,
>>>>
>>>> On Thu, 08. Jul 2021 at 10:30:08 +0200, Andreas Neumann wrote:
>>>> > attribute(@atlas_feature,'pkey_name'), but it is a little more
>>>> complicated
>>>> > than @atlas_featureid - and I'm pretty sure that @atlas_featureid was
>>>> using
>>>> > the pkey column in th past?
>>>> >
>>>> > My data source for the atlas coverage layer is a Postgis View.
>>>>
>>>> It's probably not using the column you expect for the feature id.  Did
>>>> you
>>>> specify the key column when adding the view?
>>>>
>>>>
>>>> Jürgen
>>>>
>>>> --
>>>> Jürgen E. Fischer           norBIT GmbH             Tel.
>>>> +49-4931-918175-31
>>>> Dipl.-Inf. (FH)             Rheinstraße 13          Fax.
>>>> +49-4931-918175-50
>>>> Software Engineer           D-26506 Norden
>>>> https://www.norbit.de
>>>> QGIS release manager (PSC)  Germany                 IRC: jef on
>>>> Libera|OFTC
>>>> _______________________________________________
>>>> QGIS-Developer mailing list
>>>> QGIS-Developer at lists.osgeo.org
>>>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>>>
>>>
>>>
>>> --
>>>
>>> --
>>> Andreas Neumann
>>> QGIS.ORG board member (treasurer)
>>> _______________________________________________
>>> QGIS-Developer mailing list
>>> QGIS-Developer at lists.osgeo.org
>>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>>
>>
>
> --
>
> --
> Andreas Neumann
> QGIS.ORG board member (treasurer)
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210712/e9855493/attachment.html>


More information about the QGIS-Developer mailing list