pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Geoff Winkless <pgsqladmin@geoff.dj>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: Alexandre GRAIL <postgresql.general@augure.net>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Casting Integer to Boolean in assignment
Date: Thu, 24 Jan 2019 08:00:27 -0800
Message-ID: <984fa130-e8a1-6cb0-b7f8-f57e853f8dfd@aklaver.com> (raw)
In-Reply-To: <CAEzk6feizMYvzRORT+ct-vycBBEhd2zbajZGVDNUxtzFdFM-bw@mail.gmail.com>
References: <d8fe822a-ac75-5763-00b3-273f11394fc5@augure-ng.fr>
	<CAKFQuwZXYgDxDLkB4a2jVn+bcuyxEWyROoKL8z-fwfrbS1pFgA@mail.gmail.com>
	<CAEzk6ffv_490p4z-0mKoxGcp0gVNLmkv84kCn1OvB-=mg_B+tg@mail.gmail.com>
	<17453.1548342682@sss.pgh.pa.us>
	<CAEzk6fd-KniDxJWHPMh4e0AAGuNu=Hq914kW7aeQOjE2ybNVzw@mail.gmail.com>
	<1bc32f58-a479-ee28-353f-b11810bab95e@aklaver.com>
	<CAEzk6fdybWtW6KXrV0bjYY7=2jYDxY=nDmbZBxr4+F2hfBLhwg@mail.gmail.com>
	<52d4616a-af35-68fa-a613-b823ab3d2eb4@aklaver.com>
	<CAEzk6feizMYvzRORT+ct-vycBBEhd2zbajZGVDNUxtzFdFM-bw@mail.gmail.com>

On 1/24/19 7:48 AM, Geoff Winkless wrote:
> On Thu, 24 Jan 2019 at 15:40, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
>> delete from delete_test where
>>
>> and then forget the 'field =' part. Though my more common mistake along
>> that line is:
>>
>> delete from delete_test;
>>
>> At any rate, if it can be done it will be done.
> 
> If you follow that logic, then having a single boolean test at all
> should be invalid.
> 
> CREATE TABLE mytest (myval char (1));
> INSERT INTO mytest VALUES ('a'),('b'),('c'),('s'),('t');
> DELETE FROM mytest WHERE 't';
> SELECT * FROM mytest;
>   myval
> -------
> (0 rows)

People are going to make mistakes that is a given. Eliminating a boolean 
test is not going to change that. Where this particular sub-thread 
started was with this from a previous post of yours:

"My own opinion is that non-0 should implicitly cast as true and 0
should cast as false. ..."

That opens an infinite number of values that could be seen as True. That 
in turn leads to greater chance of fat-thumbing yourself into an oops. 
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.

> 
> Geoff
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com




view thread (21+ messages)  latest in thread

Message-ID: <984fa130-e8a1-6cb0-b7f8-f57e853f8dfd@aklaver.com>
Permalink:  ../984fa130-e8a1-6cb0-b7f8-f57e853f8dfd@aklaver.com/
Also on:    postgresql.org/message-id/984fa130-e8a1-6cb0-b7f8-f57e853f8dfd@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, pgsqladmin@geoff.dj, tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, postgresql.general@augure.net
  Subject: Re: Casting Integer to Boolean in assignment
  In-Reply-To: <984fa130-e8a1-6cb0-b7f8-f57e853f8dfd@aklaver.com>
  References: <d8fe822a-ac75-5763-00b3-273f11394fc5@augure-ng.fr> <CAKFQuwZXYgDxDLkB4a2jVn+bcuyxEWyROoKL8z-fwfrbS1pFgA@mail.gmail.com> <CAEzk6ffv_490p4z-0mKoxGcp0gVNLmkv84kCn1OvB-=mg_B+tg@mail.gmail.com> <17453.1548342682@sss.pgh.pa.us> <CAEzk6fd-KniDxJWHPMh4e0AAGuNu=Hq914kW7aeQOjE2ybNVzw@mail.gmail.com> <1bc32f58-a479-ee28-353f-b11810bab95e@aklaver.com> <CAEzk6fdybWtW6KXrV0bjYY7=2jYDxY=nDmbZBxr4+F2hfBLhwg@mail.gmail.com> <52d4616a-af35-68fa-a613-b823ab3d2eb4@aklaver.com> <CAEzk6feizMYvzRORT+ct-vycBBEhd2zbajZGVDNUxtzFdFM-bw@mail.gmail.com> <984fa130-e8a1-6cb0-b7f8-f57e853f8dfd@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox