Re: Casting Integer to Boolean in assignment - Mailing list pgsql-general

From Thomas Kellerer
Subject Re: Casting Integer to Boolean in assignment
Date
Msg-id b379116f-2fc6-410c-c83d-e916bad44e50@gmx.net
Whole thread Raw
In response to Re: Casting Integer to Boolean in assignment  (Geoff Winkless <pgsqladmin@geoff.dj>)
Responses Re: Casting Integer to Boolean in assignment
List 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;



pgsql-general by date:

Previous
From: Geoff Winkless
Date:
Subject: Re: Casting Integer to Boolean in assignment
Next
From: Francisco Olarte
Date:
Subject: Re: Need a command to take the backup of the child tables along withits master table.