Re: Casting Integer to Boolean in assignment

From: Geoff Winkless <pgsqladmin(at)geoff(dot)dj>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: Geoff Winkless <pgsqladmin(at)geoff(dot)dj>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "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 16:19:51
Message-ID: CAEzk6fdXcnbgU31v+H1wkAG0PX6eyc-6_QCHEhUHt-TX2QSg-A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 24 Jan 2019 at 16:00, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> wrote:
> People are going to make mistakes that is a given. Eliminating a boolean
> test is not going to change that.

I still think that if you've got to the point where you're actually
part-way through writing a clause you're unlikely to forget to
complete it.

Missing out a clause altogether is understandable but writing half of
one? Even if you weren't sure what the value was you would probably
write

WHERE myfield=

and then have to go and look it up.

> Like you say it is a matter of opinion. The projects opinion is here:
>
> https://www.postgresql.org/docs/11/datatype-boolean.html
>
> and it works for me.

And you're welcome to it. I'm not arguing for it changing. I'm simply
stating that I'm very pleased that the default behaviour can be
changed, because in my opinion writing a bunch of explicit casts in a
query is a surefire path to unreadable code.

Geoff

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexandre GRAIL 2019-01-24 17:26:06 Re: Casting Integer to Boolean in assignment
Previous Message Adrian Klaver 2019-01-24 16:00:27 Re: Casting Integer to Boolean in assignment