0

I made a processing model in QGIS 3.10 where I calculated a integer value "mycolumn". Within the model, I refactored the "mycolumn" value to Boolean using mycolumn >= 1. As I expected, the output layer had a boolean field named "mycolumn". I copied the output layer's features to a PostGIS layer with the same setup (Boolean field named "mycolumn"). In the test case, all entries in "mycolumn" were false. When saving the layer, PostGIS throws the exception

PostGIS error while adding features: ERROR: column "mycolumn" is of type boolean but expression is of type integer LINE 1: ...S (st_geomfromwkb($1::bytea,2056),$2,528,$3,$4,$5,0,'',$6) R... ^ HINT: You will need to rewrite or cast the expression.

However, The "0" after $5 is in the position I would expect "mycolumn" to be in. Thus, I would expect the expression to be st_geomfromwkb($1::bytea,2056),$2,528,$3,$4,$5,$6,'',$7). Is this a bug and is there a workaround?

3
  • When you copied the layer to PostGIS, did you use DB Manager "Import layer/file..."? Have you tried creating a layer that contains a Boolean column without using the Processing Modeler to see if the PostGIS copy works in that case?
    – hgb
    Commented Apr 9, 2022 at 13:15
  • I didn't copy the layer, but the features in the layer by select-copy-paste. Copying from a scratch layer into a test postgis layer is working as expected (true, false and null are copied correctly)
    – cymed
    Commented Apr 11, 2022 at 12:55
  • 2
    Then 1 possible workaround is to run your model to create a layer and then use DB Manager to import the layer into your PostGIS database. That works on QGIS 3.24.1 with a Boolean column.
    – hgb
    Commented Apr 11, 2022 at 14:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.