Re: JDBC String to Bool spec

From: Jorge Solórzano <jorsol(at)gmail(dot)com>
To: Mark Rotteveel <mark(at)lawinegevaar(dot)nl>
Cc: List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: JDBC String to Bool spec
Date: 2017-01-16 20:27:30
Message-ID: CA+cVU8NPc57kWe0iFJyMgsYuYDMo+2VKmDhJ32zq1FMM+WFRXg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Mon, Jan 16, 2017 at 2:09 PM, Mark Rotteveel <mark(at)lawinegevaar(dot)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
>
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kevin Wooten 2017-01-16 20:28:52 Re: JDBC String to Bool spec
Previous Message Kevin Wooten 2017-01-16 20:22:06 Re: JDBC String to Bool spec