Re: Casting Integer to Boolean in assignment

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Casting Integer to Boolean in assignment
Date: 2019-01-24 12:17:52
Message-ID: b379116f-2fc6-410c-c83d-e916bad44e50@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Geoff Winkless schrieb am 24.01.2019 um 12:45:
> The reason for that at least is that '1' and '0' are valid boolean values.
>
> https://www.postgresql.org/docs/9.5/datatype-boolean.html
>
> There's additional text describing why casts are chosen to be defined
> as implicit or not here
>
> https://www.postgresql.org/docs/9.5/typeconv-overview.html
>
> My own opinion is that non-0 should implicitly cast as true and 0
> should cast as false.

I strongly disagree - that would mimic MySQL's idiosyncrasies and would make such a query valid:

delete from orders
where 42;

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Francisco Olarte 2019-01-24 12:35:03 Re: Need a command to take the backup of the child tables along with its master table.
Previous Message Geoff Winkless 2019-01-24 11:45:54 Re: Casting Integer to Boolean in assignment