pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
To: pgsql-jdbc@postgresql.org
Subject: Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)
Date: Fri, 01 Oct 2010 11:09:33 +1300
Message-ID: <4CA50A9D.2030707@catalyst.net.nz> (raw)
In-Reply-To: <1285883402563-3047721.post@n5.nabble.com>
References: <1285701298407-2865634.post@n5.nabble.com>
	<4CA22C3C0200002500036065@gw.wicourts.gov>
	<1285716712781-2916249.post@n5.nabble.com>
	<4CA28CCB.5020400@opencloud.com>
	<1285762010765-3005405.post@n5.nabble.com>
	<4CA338F8.80902@opencloud.com>
	<4CA499DB.8000807@postnewspapers.com.au>
	<4CA4F536.5050704@opencloud.com>
	<1285880740264-3047671.post@n5.nabble.com>
	<4CA503A2.7010706@opencloud.com>
	<1285883402563-3047721.post@n5.nabble.com>

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



view thread (53+ messages)  latest in thread

Message-ID: <4CA50A9D.2030707@catalyst.net.nz>
Permalink:  ../4CA50A9D.2030707@catalyst.net.nz/
Also on:    postgresql.org/message-id/4CA50A9D.2030707@catalyst.net.nz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: mark.kirkwood@catalyst.net.nz
  Subject: Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)
  In-Reply-To: <4CA50A9D.2030707@catalyst.net.nz>
  References: <1285701298407-2865634.post@n5.nabble.com> <4CA22C3C0200002500036065@gw.wicourts.gov> <1285716712781-2916249.post@n5.nabble.com> <4CA28CCB.5020400@opencloud.com> <1285762010765-3005405.post@n5.nabble.com> <4CA338F8.80902@opencloud.com> <4CA499DB.8000807@postnewspapers.com.au> <4CA4F536.5050704@opencloud.com> <1285880740264-3047671.post@n5.nabble.com> <4CA503A2.7010706@opencloud.com> <1285883402563-3047721.post@n5.nabble.com> <4CA50A9D.2030707@catalyst.net.nz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox