Re: [JDBC] JDBC String to Bool spec

Поиск
Список
Период
Сортировка
От Jorge Solórzano
Тема Re: [JDBC] JDBC String to Bool spec
Дата
Msg-id CA+cVU8OTCz2Tx3SDmAvKfur=PbKK9WoQjm67vZU_ae-QGknQVQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [JDBC] JDBC String to Bool spec  (Jorge Solórzano <jorsol@gmail.com>)
Ответы Re: [JDBC] JDBC String to Bool spec  (Kevin Wooten <kdubb@me.com>)
Re: JDBC String to Bool spec  (Kevin Wooten <kdubb@me.com>)
Список pgsql-jdbc
BTW, the JDBC specs (or at least the javadocs) reads this:

If the designated column has a datatype of CHAR or VARCHAR and contains a "0" or has a datatype of BIT, TINYINT, SMALLINT, INTEGER or BIGINT and contains a 0, a value of false is returned. If the designated column has a datatype of CHAR or VARCHAR and contains a "1" or has a datatype of BIT, TINYINT, SMALLINT, INTEGER or BIGINT and contains a 1, a value of true is returned.

So this use case is already covered, but I think that having full postgres conversion is a better approach.
 

Jorge Solórzano
me.jorsol.com

On Sun, Jan 15, 2017 at 6:59 PM, Jorge Solórzano <jorsol@gmail.com> wrote:
Maybe we should support postgres conversion (https://www.postgresql.org/docs/current/static/datatype-boolean.html), similar to what is already on PgPreparedStatement and setObject.

Can you please open an issue on github to keep track of it?

Jorge Solórzano
me.jorsol.com

On Sun, Jan 15, 2017 at 5:54 PM, Kevin Wooten <kdubb@me.com> wrote:
It’s not my use case.  It seems to me the driver should either support JDBC/Java conversions (true/yes => true, everything else false) or Postgres conversions (true/on/t/1 => true, false/off/f/0 => false, everything else error).  

Currently it seems theres a hodgepodge of supported conversion not really defined by the spec or server support; unless they are defined somewhere that I’m not aware off.

On Jan 15, 2017, at 4:42 PM, Dave Cramer <pg@fastcrypt.com> wrote:


On 15 January 2017 at 18:33, Kevin Wooten <kdubb@me.com> wrote:
Actually this table isn’t what I’m looking for.  Related to example I provided below, there doesn’t seem to be a list of “acceptable values” when converting a string to a boolean; only that “getBoolean” must support conversion from VARCHAR/CHAR.



Ya I thought you were looking for something else. Not sure how you deal with your exact use case



 
On Jan 15, 2017, at 4:29 PM, Kevin Wooten <kdubb@me.com> wrote:

Thanks… is there a reason those tables were dropped from the 4.2 spec PDF?

On Jan 15, 2017, at 4:26 PM, Dave Cramer <pg@fastcrypt.com> wrote:



On 15 January 2017 at 18:20, Kevin Wooten <kdubb@me.com> wrote:
Does anybody know where in the specification it details the required/acceptable conversions from string values to boolean?  I cannot seem to find it in the PDF for 4.2.

I am curious about some of the conversions that are done.  For example, calling “ResultSet.getBoolean” on a text/varchar column with the value “1.0”.  This conversion succeeds because the driver (both pgjdbc & ng) fallback to decoding the column as a double then converting that by testing it “== 1”; which seems valid but questionable since “!= 0” would also be valid, but vastly different.

This is not allowed by Postgres (e.g. “SELECT “1.0”::bool;” results in an error) and I cannot find anything in JDBC as of yet.

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







В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Jorge Solórzano
Дата:
Сообщение: Re: [JDBC] JDBC String to Bool spec
Следующее
От: Kevin Wooten
Дата:
Сообщение: Re: [JDBC] JDBC String to Bool spec