Anton Melser wrote: > Hi, > I am trying to port an app to postgres and have come up against a most > annoying problem. The app works with both mysql and sqlserver, who > both seem to have a bit datatype instead of a proper boolean like pg. > Alas, pg won't accept 1 and 0 for boolean... and npgsql won't convert > my numeric(1) into a boolean (and shouldn't either!). Is there any way > to force pg to accept 1 and 0 for boolean? I know it probably isn't > optimal, but hey. If there is a standard way to do this (and no, > rewriting is not an option) I'm all ears. > Cheers > Antoine postgres=# insert into bool_test values(1::boolean); INSERT 166968558 1 postgres=# insert into bool_test values(0::boolean); INSERT 166968559 1 postgres=# select * from bool_test ; one ----- t f (2 rows) postgres=# postgres=# insert into bool_test values(cast(0 as boolean)); INSERT 166968560 1 postgres=# insert into bool_test values(cast(1 as boolean)); INSERT 166968561 1 postgres=# select * from bool_test ; one ----- t f f t (4 rows) > > ---------------------------(end of broadcast)--------------------------- > TIP 6: explain analyze is your friend > -- === The PostgreSQL Company: Command Prompt, Inc. === Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240 Providing the most comprehensive PostgreSQL solutions since 1997 http://www.commandprompt.com/ Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate PostgreSQL Replication: http://www.commandprompt.com/products/