[QGIS-Developer] Default QgsFeatureFid ?

Greg Troxel gdt at lexort.com
Fri Oct 15 05:12:07 PDT 2021


Sandro Santilli <strk at kbt.io> writes:

> On Fri, Oct 15, 2021 at 10:45:52AM +0200, Alessandro Pasotti wrote:
>> Hi,
>> 
>> maybe you can use
>> 
>> #define FID_NULL            std::numeric_limits<QgsFeatureId>::min()
>
> Maybe, but the question is more generic: *should* a QgsFeatureId have
> a default value ?

There's a larger question lurking behind that, which is something about
if tables in SQL can have NULL values and how that NULL is mapped into
qgis's main internal representation and then back out to various
formats.  (I know there's a great CJ Date rant about NULL not belonging
in SQL and how it is a symptom of denormalized data, but it is how it is
these days.)

That said, it seems obvious that SQL NULL should map to FID_NULL on
reading.

About

  std:numeric_limits<std::numeric_limits<QgsFeatureId>::min()

that would seem to end up with a different value on different systems,
although if QgsFeatureId is a fixed-width type that might require 2s vs
1s complement.

I guess something like FeatureId really does need to have a reserved
NULL value, or we need a rule that it can't be.

Not about qgis, but in an unusual corner Home Assistant I have run into
a problem with varying representations of the same semantics, leading to
incorrect behavior.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20211015/893780c0/attachment.sig>


More information about the QGIS-Developer mailing list