[prev in list] [next in list] [prev in thread] [next in thread] 

List:       dbi-dev
Subject:    Re: Boolean data types and the DBI
From:       Michael Peppler <mpeppler () mbay ! net>
Date:       1997-09-29 12:41:12
[Download RAW message or body]

    *** From dbi-users -- To unsubscribe, see the end of this message. ***

Tim Bunce wrote:
> 
>     *** From dbi-dev -- To unsubscribe, see the end of this message. ***
> 
> > From: Edmund Mergl <E.Mergl@bawue.de>
> >
> > PostgreSQL accepts almost anything as input for the datatype bool:
> >
> >       0  -> false
> >       1  -> false
> 
> Arrrgh! Are you _sure_ about that one?
> 
> >      'f' -> false
> >      't' -> true
> >  'false' -> false
> >   'true' -> true
> >
> > It returns 'f' for false and 't' for true.
> >
> > I think for the application programmer it would
> > be a nice feature not having to take care about the
> > peculiarities of every database.
> 
> I can't agree more.
> 
> The only reasonable default behaviour for the DBI to specify is use
> of 0 and 1 on both input and output. It also works well with
> databases that have a BIT type where a type of BIT(1) is used for
> boolean fields.

As a (sort of) aside, I've seen Access map Sybase's bit field to 0 and
-1 (!).

> 
> There's only a problem with drivers that can't tell that their dealing
> with a boolean field. In that case selects could return "f" and
> bind_param($field, $value = 1) could cause the statement to fail
> if, for example, only "t" and "f" are valid.
> 
> Sigh.
> 
> So, for Postgress (and other databases supporting a "boolean" data type),
> can you change the driver to return 0 or 1 for boolean fields?
> 
> And treat (!SvTRUE(sv)) as false.
> 

Michael
-- 
Michael Peppler       -||-  Data Migrations Inc.
mpeppler@datamig.com  -||-  http://www.mbay.net/~mpeppler


------------------------------------------------------------------------------
To unsubscribe from this list, please visit http://www.fugue.com/dbi.
If you are without web access, or if you are having trouble with the web page,
please send mail to dbi-request@fugue.com.   Please try to use the web
page first - it will take a long time for your request to be processed by hand.
------------------------------------------------------------------------------

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic