pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: Thomas Kellerer <spam_eater@gmx.net>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: bit datatype and getObject()
Date: Wed, 24 Nov 2010 01:31:13 -0500 (EST)
Message-ID: <alpine.BSO.2.00.1011240122570.13088@leary.csoft.net> (raw)
In-Reply-To: <ichd9g$e1g$1@dough.gmane.org>
References: <ichd9g$e1g$1@dough.gmane.org>



On Tue, 23 Nov 2010, Thomas Kellerer wrote:

> the JDBC driver seems to map columns defined as "bit" to Boolean regardless 
> of the definition of the column. So even a bit(5) is returned as boolean 
> value which I think is not correct.
>
> Consider the following
>
> CREATE TABLE bit_test (some_bits bit(5));
> INSERT INTO bit_test VALUES ('01010');
>
> When I run a select in psql it will return 01010 as the column's value.
>
> When running a select from within Java and using getObject() on that column a 
> java.lang.Boolean is returned.
>
> This might be correct for a bit(1) but not for columns defined with a bigger 
> width.
>
> I'm not sure what the JDBC specs requires here, but this mapping somehow is 
> confusing.

Yeah, losing data is not good.  Previously the discussion on list was to 
use java.util.BitSet, but it never resulted in a patch.  I'm not sure if 
we can retain backwards compatibility for single bit length bitstrings. 
So we'd have to determine whether we can maintain compatibility and if 
not, is it still worth it to use BitSet.

Kris Jurka



view thread (8+ messages)  latest in thread

Message-ID: <alpine.BSO.2.00.1011240122570.13088@leary.csoft.net>
Permalink:  ../alpine.BSO.2.00.1011240122570.13088@leary.csoft.net/
Also on:    postgresql.org/message-id/alpine.BSO.2.00.1011240122570.13088@leary.csoft.net

 · 

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: books@ejurka.com, spam_eater@gmx.net
  Subject: Re: bit datatype and getObject()
  In-Reply-To: <alpine.BSO.2.00.1011240122570.13088@leary.csoft.net>
  References: <ichd9g$e1g$1@dough.gmane.org> <alpine.BSO.2.00.1011240122570.13088@leary.csoft.net>

* 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