Re: JDBC String to Bool spec - Mailing list pgsql-jdbc

From Jorge Solórzano
Subject Re: JDBC String to Bool spec
Date
Msg-id CA+cVU8NPc57kWe0iFJyMgsYuYDMo+2VKmDhJ32zq1FMM+WFRXg@mail.gmail.com
Whole thread Raw
In response to Re: [JDBC] JDBC String to Bool spec  (Mark Rotteveel <mark@lawinegevaar.nl>)
List pgsql-jdbc
On Mon, Jan 16, 2017 at 2:09 PM, Mark Rotteveel <mark@lawinegevaar.nl> wrote:

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

Let's assume that someone writes crappy code​, and that in the database there is a column varchar(10) and it allows any value, then the developer wants to get the boolean of that, and in that column there are those values:

t,
TRUE,
FULSE,
yes, ok,
si,
NO, maybe

So, what if someone thinks that "ok" will return TRUE, if the conversion is allowed this will return FALSE, and you will get a wrong behaviour.
If for instance the database have only valid values, YES, NO, TRUE, FALSE, 1, 0 ON, OFF, then this won't break anything. It will break only when someone is doing something bad, so essentially most good code will work without changing a single line of code.

 I think is far more dangerous to blindly accept any value and cast it to false, that to reject it early.




Mark

pgsql-jdbc by date:

Previous
From: Kevin Wooten
Date:
Subject: Re: JDBC String to Bool spec
Next
From: Kevin Wooten
Date:
Subject: Re: [JDBC] JDBC String to Bool spec