Re: getting postgres to emulate mysql/sqlserver bit datatype - Mailing list pgsql-general

From Jeff Davis
Subject Re: getting postgres to emulate mysql/sqlserver bit datatype
Date
Msg-id 1171307619.10824.101.camel@dogma.v10.wvs
Whole thread Raw
In response to Re: getting postgres to emulate mysql/sqlserver bit datatype  ("Anton Melser" <melser.anton@gmail.com>)
List pgsql-general
On Mon, 2007-02-12 at 09:09 +0100, Anton Melser wrote:
> 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.

Can you just do something simple like:

CREATE DOMAIN intbool AS integer CHECK (VALUE IN (0,1));

and convert the data type to that?

Then, can you tell npgsql to map the database's intbool type to the
application's bool type?

Regards,
    Jeff Davis


pgsql-general by date:

Previous
From: Bill Moseley
Date:
Subject: Re: Adjacency List or Nested Sets to model file system hierarchy?
Next
From: "Melvin Davidson"
Date:
Subject: Function to return list of all prime numbers in range