Sandro Santilli <[email protected]> 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.
signature.asc
Description: PGP signature
_______________________________________________ QGIS-Developer mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
