opengisch / QgisModelBaker

Create QGIS projects from database schemas or Interlis models
https://opengisch.github.io/QgisModelBaker/
GNU Lesser General Public License v3.0
55 stars 17 forks source link

Model Baker Import thwarts non-mandatory boolean #933

Closed el-wiss closed 5 months ago

el-wiss commented 5 months ago

INTERLIS makes a distinction between a MANDATORY BOOLEAN and a BOOLEAN. The latter allows its value to be NULL. This is also possible in both PostGIS (true/false/NULL) and GeoPackage (0/1/NULL). The following screenshot shows the corresponding table from the GeoPackage specification: https://www.geopackage.org/spec/ geopackage_boolean

However, the model baker import always sets a NOT NULL-constraint when importing a BOOLEAN attribute from INTERLIS, This behaviour cannot be altered (except in PostGIS by manually removing the constraint via SQL statement after importing the schema). modelbaker_boolean_not_null

true/false/NULL boolean type situations often exist in the real world and both INTERLIS and the databases allow them to be modeled as such. Therefore, model baker should offer an option for this behaviour to be (de)selected by the users.

signedav commented 5 months ago

I cannot reproduce. When I import this model:

INTERLIS 2.3;

MODEL Booltest (de)
AT "http://modelbaker.ch"
VERSION "2024-06-17"  =

  TOPIC Booltest =
    CLASS Booltest =
      NullBool : BOOLEAN;
      NotNullBool : MANDATORY BOOLEAN;
    END Booltest; 
  END Booltest;
END Booltest.

My settings are this: image

And this: image

So it does not set the constraint on where it's not needed...

But there is something else: When you allow null in QGIS it still sets it always to false. To allow null you have to activate it: image

But I don't think that's your problem @el-wiss What Model Baker version you are using? Have you tested with the most recent official version?

el-wiss commented 5 months ago

Your're right, thanks for reproducing. I used version 7.8.4. - seems like i've mixed up similarly named attributes within a model after a long day's work. I retested it today and ended up with your result.

The well known QGIS issue (qgis showing "false" in attribute table on NULL-values in boolean fields) is still a nuisance, but that's not a model baker issue.