Re: JDBC String to Bool spec

Поиск
Список
Период
Сортировка
От Jorge Solórzano
Тема Re: JDBC String to Bool spec
Дата
Msg-id CA+cVU8NPc57kWe0iFJyMgsYuYDMo+2VKmDhJ32zq1FMM+WFRXg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [JDBC] JDBC String to Bool spec  (Mark Rotteveel <mark@lawinegevaar.nl>)
Список 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 по дате отправления:

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