Re: getting postgres to emulate mysql/sqlserver bit datatype

From: "Anton Melser" <melser(dot)anton(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: getting postgres to emulate mysql/sqlserver bit datatype
Date: 2007-02-12 08:09:32
Message-ID: 92d3a4950702120009q3ef82230s6e02a77375a0c8fb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 12/02/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "Joshua D. Drake" <jd(at)commandprompt(dot)com> writes:
> > Anton Melser wrote:
> >> Is there any way
> >> to force pg to accept 1 and 0 for boolean?
>
> > postgres=# insert into bool_test values(1::boolean);
> > INSERT 166968558 1
> > postgres=# insert into bool_test values(0::boolean);
> > INSERT 166968559 1
>
> Possibly Anton is using an old version in which there wasn't a built in
> int-to-bool cast?

In my searching I did turn up a comment (maybe from you even!) about
how it wouldn't work (before at least). I guess my problem is that
there is a body of sql that can't be changed, or at least the other
devs aren't interested enough in pg support to let me add a ton of if
pg else code. I think that creating a type is probably the way to go,
though if anyone has any advice I'm all ears.
I have .net code which has things like
bool myBool = datareader.GetBoolean(datareader.GetOrdinal("my_bool"));
Or something similar (I'm at work...). So I need to be able for npgsql
to return a boolean, but also need to be able to insert and compare
with straight 1, 0. I suppose there is a way that I can get around it
but after a couple of hours I haven't been able to come up with
anything.
Cheers
Anton

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2007-02-12 08:19:15 Re: [SQL] Password Policy
Previous Message Rafael Martinez, Guerrero 2007-02-12 08:06:33 Re: How to set UTF8 to query browser of PgAdmin III