From: | rob stone <floriparob(at)gmail(dot)com> |
---|---|
To: | Jorge Solórzano <jorsol(at)gmail(dot)com>, Kevin Wooten <kdubb(at)me(dot)com> |
Cc: | Dave Cramer <pg(at)fastcrypt(dot)com>, "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: JDBC String to Bool spec |
Date: | 2017-01-16 21:16:02 |
Message-ID: | 1484601362.6580.1.camel@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Hello,
> >
> > Since we now know the JDBC spec doesn’t support this (thanks to all
> > of Mark Rotteveel’s sleuthing) & we know Postgres doesn’t support
> > this. It seems the “feature" should be removed or placed behind an
> > option. Postgres results in an error here and considering this is
> > a driver tied to that database I look to that to clarify ambiguity.
> > These examples should all result in an error.
> >
> >
> >
>
> Yes, I agree, a "feature" that allows bad code should be considered
> a "bug".
>
>
The OP in the original post used a string of "1.0" and wanted to
convert it into a boolean. If you use setBoolean in a prepared
statement it expects the argument to be a "numeric" type, so it is not
surprising that the string was converted to a double. You'd expect
something along the lines of ps.setBoolean(5,"xyz") to throw an error.
I don't know how many string values are to be considered "true" in the
application. Maybe use some regular expressions to suss out "true"
values?
My two cents.
Rob
From | Date | Subject | |
---|---|---|---|
Next Message | Kevin Wooten | 2017-01-16 21:20:32 | Re: JDBC String to Bool spec |
Previous Message | Jorge Solórzano | 2017-01-16 20:32:35 | Re: JDBC String to Bool spec |