On 01/10/10 10:50, stagirus wrote:
> Oliver: Thank you for your generous response. The options you suggested were
> not yet viable. Disagreeing is part of human nature. No worries there.
>
> But if you review Craig's remarks carefully, this issue is likely outside
> the scope of JDBC drivers. It is more to do with the Postgresql DB Engine
> that is not happy to cast or convert boolean values to SMALLINT columns.
>
> Craig.. is my interpretation of your comments right?
>
>
This could be an interesting related factor (using 9.0 here):
test=# create table smallinttest(val smallint);
CREATE TABLE
test=# create table booltest(val bool);
CREATE TABLE
test=# insert into booltest values (1);
ERROR: column "val" is of type boolean but expression is of type integer
LINE 1: insert into booltest values (1);
test=# insert into booltest values ((1::smallint)::bool);
ERROR: cannot cast type smallint to boolean
LINE 1: insert into booltest values ((1::smallint)::bool);
^
^
HINT: You will need to rewrite or cast the expression.
test=# insert into booltest values (1::bool);
INSERT 0 1
test=# insert into smallinttest values (true);
ERROR: column "val" is of type smallint but expression is of type boolean
LINE 1: insert into smallinttest values (true);
^
HINT: You will need to rewrite or cast the expression.
test=# insert into smallinttest values (true::smallint);
ERROR: cannot cast type boolean to smallint
LINE 1: insert into smallinttest values (true::smallint);
^
test=# insert into smallinttest values (true::int);
INSERT 0 1
So looks like we are missing type casts BOOLEAN <-> SMALLINT, given that
we can happily cast to and from INTEGER.
Before getting too excited, note that the server is clearly not doing
automated casts under any circumstances, I had to coerce it - so might
not help you even if we added such casts.
Cheers
Mark