I have a Postgresql database that uses the boolean type for lots of columns. I want to use a checkbox to specify ‘true’ or ‘false’, but Servoy doesn’t seem to like this; when I tick the box and move off of it, I get this error:
Cannot save form data
org.postgresql.util.PSQLException: ERROR: column “columnname” is of type boolean but expression is of type integer
ERROR: column “columnname” is of type boolean but expression is of type integer
Besides altering the database to use an int type (so it would support 1/0, which I would guess Servoy is sending), which is not an option, how can I make this work in Servoy?
The current documentation for this type is here, and it seems Postgres DOES support 1/0, but only when quoted… is there a way to alter what Servoy sends to the db when ticking/unticking the box?
Better yet, is there native support for this happening any time soon? This is causing large problems with our solution.
Servoy info:
Version R2 2.1-build 310
Java version 1.4.2_04-b05 (Linux)
Perhaps if there are enough of us, accounting for the Postgresql boolean type can move farther up the “to do” list of feature requests. As far as I know the boolean type is part of the SQL standard. Is the problem only with Postgresql’s implementation or do other DBMS’ not use the boolean type?
BTW - we don’t have that many booleans, but the way we’ve worked around it up to now is to add integer fields to the tables that Servoy interacts with - and these mirror the boolean fields (which are used in a bunch of backend functions and accessed elsewhere). A backend trigger function keeps the fields in sync. It’s kludgy and a pain, but it works.
we will look into this.
But the driver is the problem as far as we see. The driver should be able to convert a Integer to a boolean just fine. So we are looking into it to fix the driver for postgresql and send that fix to them.
Hi,
I am not sure if this will help but here it is.
Javascript boolean is “true” or “false” so you should parse them to “0” or “1” in order not to get that error.
There are two ways to make javascript boolean be numbers.
Number(boolean) or 0 + boolean. In the last when you add “0” to a javascript boolean it gets converted to integer.
Best Regards,
Miguel Angel