From: | Leif Biberg Kristensen <leif(at)solumslekt(dot)org> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: An amusing MySQL weakness--not! |
Date: | 2011-06-27 10:11:21 |
Message-ID: | 201106271211.21363.leif@solumslekt.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sunday 26. June 2011 16.11.06 Vincent Veyron wrote:
> Le dimanche 26 juin 2011 à 00:05 -0700, Darren Duncan a écrit :
> > Michael Nolan wrote:
> >
> > Having real BOOLEAN is just one of the reasons I like Postgres the most.
>
> Would you mind giving an example of where a boolean field would be a win
> over an integer one?
>
> I'm asking this because I frequently wonder what is best for my use; I
> normally query postgres via Perl modules, which don't care about boolean
> (the driver converts t/f to 0/1), but I like to tune my fields properly.
PHP has its own Boolean values TRUE/FALSE, but reads Postgresql Booleans as
't'/'f'. You always have to rely on kludgy konstructs like
if ($pg_bool == 't') then
$my_bool = TRUE;
elseif ($pg_bool == 'f') then
$my_bool = FALSE;
else
$my_bool = NULL;
It's of course much easier to use integer values, but it sucks not to use a
bool when you want a variable that can't be anything but TRUE, FALSE or NULL.
It obfuscates the code to use a var that evaluates to an integer, but in
reality is a Boolean in disguise.
regards, Leif
From | Date | Subject | |
---|---|---|---|
Next Message | Albe Laurenz | 2011-06-27 11:54:32 | Re: Reusing cached prepared statement slow after 5 executions |
Previous Message | mephysto | 2011-06-27 09:47:44 | Re: Custom types as parameter in stored function |