using boolean in Postgres for relation

I am not sure if this the correct forum. But here goes.

I am using Postgres 9. In the design of a new table I specified a boolean for a column: “is_posted”.
I would like make a relation from table A to table B with two conditions:
table A.contact_id == table B.contact_id_fk
AND
globals.vg_const_true == table B.is_posted

where globals.vg_const_true has to be set to the equivalent of “TRUE” ie the boolean or “1” if it was an Integer.

So far I have errors attempting to make this global the correct type to be able to do the relation.

I know I can redefine the table B.is_posted to be an integer (TinyInt or Bit or whatever makes sense in the particular DB).
However Servoy will not allow the boolean type to be used in the relation.

Interestingly when I have a javascript code such as:
is_posted = true;
Servoy gives an error (or is it Rhino?) and I can only use:
is_posted = 1;//“true”

So why is there this difference - probably because the Servoy abstraction of the DB server maps any boolean to integer?

Is there any future type enhancements to be able to define a global as a Boolean type (note that media does not work either).

Tom,

What happens if you use boolean in the table and value 1 in the global?

Rob

@Rob,
yes setting a constant 1 as a global does work in setting the relationship to a Postgres boolean.

I just did another search on this kind of issue oin the forum and found this reference topic a few years back.
http://www.servoy.com/forum/viewtopic.php?f=8&t=2913&p=13462&hilit=postgres+boolean#p13462
Perhaps Servoy staff could update us now that Postgres is becoming wider used in the community?

More specifically, if I do have booleans defined in the database (and I am not allowed to change that db design) what is the “best” practice to handle in Servoy (as integers etc).

My current issue is that I am doing a datasetByQuery and the where expression is:

where is_selected = ? 

is_selected is defined a boolean in Postgre but Servoy translates that to integer
I defined the “?” as 1 like:

var args = new Array();
args[0] = 1;

the error message is:

ERROR: operator does not exist: boolean = double precision

When I define the “?” as

args[0] = true;

Then I get the correct response when I use a ‘boolean’ but in other places I have to use integer.

IS this the best way to do it?

Tom,

This is changed in Servoy 6, Servoy will send a boolean in stead of a number for boolean columns.

Also you can use a boolean global with the relation (the int global will still work)

Rob

:D

Cheers!