Re: Casting Integer to Boolean in assignment

From: Geoff Winkless <pgsqladmin(at)geoff(dot)dj>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Geoff Winkless <pgsqladmin(at)geoff(dot)dj>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Alexandre GRAIL <postgresql(dot)general(at)augure(dot)net>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Casting Integer to Boolean in assignment
Date: 2019-01-24 15:21:46
Message-ID: CAEzk6fd-KniDxJWHPMh4e0AAGuNu=Hq914kW7aeQOjE2ybNVzw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 24 Jan 2019 at 15:11, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> People don't generally post to the lists after a type-mismatch error
> catches a typo for them. So it's pretty hard to tell about "how
> many" developers would find one behavior more useful than the other.
> It is safe to say, though, that the same developer complaining today
> might have their bacon saved tomorrow.

I've missed off WHERE clauses on a live database (oops) in my time,
and I'm happy to see work being done to safeguard against that
(although I tend to be of the opinion that it's not something you ever
do twice!) but I can confidently state that I've never once been
caught out by being surprised that a number was treated as a boolean.

How could you even write a query like the one Thomas posted? It
doesn't even look remotely sensible.

But I have been caught out by boolean vs int, enough that I bothered
to search out that ALTER statement. And I'm a lazy person at heart, so
if something irritated me enough to bother doing that, you can be sure
it was _really_ irritating me.

Geoff

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2019-01-24 15:23:34 Re: log_min_duration_statement
Previous Message Adrian Klaver 2019-01-24 15:17:57 Re: Casting Integer to Boolean in assignment