pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Rotteveel <mark@lawinegevaar.nl>
To: pgsql-jdbc@postgresql.org
Subject: Re: JDBC String to Bool spec
Date: Mon, 16 Jan 2017 21:09:41 +0100
Message-ID: <7c2e158ed4db19a6bb66ad369e6fd233@lawinegevaar.nl> (raw)
In-Reply-To: <CA+cVU8MFAfRad8Bba-049nk_9KKd-14FnW7An78W3S=_EZ5sww@mail.gmail.com>
References: <990BE54A-5803-4B5A-A5C8-BD6DBE75B72C@me.com>
	<CADK3HHJQiDaExrbJf1n9vQmkq67XibcdBw6TWMDsBV0rKoV9Bw@mail.gmail.com>
	<67BD0617-E3A5-43BD-9770-6C2611187092@me.com>
	<83AB5852-8884-465E-80D8-A49B6CB05A88@me.com>
	<CADK3HHJg0mVo5AaD-oYUNCSb97GZPXn26hP-0wgtcgy_gTNkTQ@mail.gmail.com>
	<0AA59CB8-5010-4E1A-A631-DF7819F40EE5@me.com>
	<CA+cVU8OwF16Y=vGetySafj8B0Sa4pr_1DUCMW22P_GR6AtGW6A@mail.gmail.com>
	<CA+cVU8OTCz2Tx3SDmAvKfur=PbKK9WoQjm67vZU_ae-QGknQVQ@mail.gmail.com>
	<C52099C7-267A-4588-94F7-A9C913673F67@me.com>
	<CA+cVU8MFAfRad8Bba-049nk_9KKd-14FnW7An78W3S=_EZ5sww@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>

On 2017-01-16 20:16, Jorge Solórzano wrote:
> I guess you are right, the driver currently blindly converts incorrect
> values to false, IMO it should accept only values allowed in
> postgresql server since this is the PgJBDC driver, but is should also
> support a cast of float, double and decimal as this is required by the
> jdbc spec.

Interestingly, the JDBC 4.2 specification documentation allows more 
types than the apidoc (see my previous email for a quote of the apidoc). 
I will see if I can get Lance Andersen to amend the apidoc.

The JDBC specification mentions conversion for: TINYINT, SMALLINT, 
INTEGER, BIGINT, REAL, FLOAT, DOUBLE, DECIMAL, NUMERIC, BIT, BOOLEAN, 
CHAR, VARCHAR, LONGVARCHAR (and vice versa), the apidoc doesn't mention 
the fixed and floating point types. Presumably this was added because 
you can also call getInt on a double, etc.

> @vlsi, @davecramer, what is your opinion about blindly convert
> incorrect values to false? Should the driver accept this kind of
> behaviour?
> 
> For instance something like this is allowed (and there is even a test
> for this):
> 
> CREATE TABLE testboolstring (a varchar(30));
> INSERT INTO testboolstring VALUES('this is not true');
> 
> when execute rs.getBoolean(1), it gets false, but it should be an
> cannotCastException.

You're right, but the question is: will you break existing code if you 
apply this change?

Mark


-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



view thread (26+ messages)  latest in thread

Message-ID: <7c2e158ed4db19a6bb66ad369e6fd233@lawinegevaar.nl>
Permalink:  ../7c2e158ed4db19a6bb66ad369e6fd233@lawinegevaar.nl/
Also on:    postgresql.org/message-id/7c2e158ed4db19a6bb66ad369e6fd233@lawinegevaar.nl

 · 

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@lawinegevaar.nl
  Subject: Re: JDBC String to Bool spec
  In-Reply-To: <7c2e158ed4db19a6bb66ad369e6fd233@lawinegevaar.nl>
  References: <990BE54A-5803-4B5A-A5C8-BD6DBE75B72C@me.com> <CADK3HHJQiDaExrbJf1n9vQmkq67XibcdBw6TWMDsBV0rKoV9Bw@mail.gmail.com> <67BD0617-E3A5-43BD-9770-6C2611187092@me.com> <83AB5852-8884-465E-80D8-A49B6CB05A88@me.com> <CADK3HHJg0mVo5AaD-oYUNCSb97GZPXn26hP-0wgtcgy_gTNkTQ@mail.gmail.com> <0AA59CB8-5010-4E1A-A631-DF7819F40EE5@me.com> <CA+cVU8OwF16Y=vGetySafj8B0Sa4pr_1DUCMW22P_GR6AtGW6A@mail.gmail.com> <CA+cVU8OTCz2Tx3SDmAvKfur=PbKK9WoQjm67vZU_ae-QGknQVQ@mail.gmail.com> <C52099C7-267A-4588-94F7-A9C913673F67@me.com> <CA+cVU8MFAfRad8Bba-049nk_9KKd-14FnW7An78W3S=_EZ5sww@mail.gmail.com> <7c2e158ed4db19a6bb66ad369e6fd233@lawinegevaar.nl>

* 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