Re: How to implement Microsoft Access boolean (YESNO)

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, "Jesper K(dot) Pedersen" <jkp(at)solnet(dot)homeip(dot)net>, pgsql-sql(at)postgresql(dot)org
Subject: Re: How to implement Microsoft Access boolean (YESNO)
Date: 2006-01-24 05:03:48
Message-ID: 87r76yusi3.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> Greg Stark <gsstark(at)mit(dot)edu> writes:
> > "Jesper K. Pedersen" <jkp(at)solnet(dot)homeip(dot)net> writes:
> >> Having checked the I/O format it seems that MS Access exports the
> >> values of a YESNO field as 0 and 1
>
> > If only Postgres's boolean type were as helpful.
>
> There's a cast to int in 8.1, and you can roll-your-own easily in prior
> releases ...

The annoying thing about is that in just about any client language you'll get
't' and 'f' by default and both will evaluate to false. So any user who tries
to do things the obvious way like this will get a surprise:

if ($db->query("select canlogin from users where userid = ?",$userid)) {
...
}

Is there an implicit cast from ints? So if I pass a 0 or 1 argument for a
boolean parameter now it'll work? That definitely didn't work in the past.

--
greg

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Bruno Wolff III 2006-01-24 09:04:39 Re: non-equi self-join optimization
Previous Message Tom Lane 2006-01-23 21:02:12 Re: How to implement Microsoft Access boolean (YESNO)