pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PFC <lists@peufeu.com>
To: pgsql-sql@postgresql.org
Subject: Re: How to implement Microsoft Access boolean (YESNO)
Date: Tue, 24 Jan 2006 11:14:58 +0100
Message-ID: <op.s3vn28xdcigqcu@apollo13> (raw)
In-Reply-To: <87r76yusi3.fsf@stark.xeocode.com>
References: <20060122211351.371f20d8@io.solnet>
	<22008.1137962771@sss.pgh.pa.us>
	<20060122221328.433038a9@io.solnet>
	<873bjewts8.fsf@stark.xeocode.com>
	<8505.1138050132@sss.pgh.pa.us>
	<87r76yusi3.fsf@stark.xeocode.com>

On Tue, 24 Jan 2006 06:03:48 +0100, Greg Stark <gsstark@mit.edu> wrote:

> Tom Lane <tgl@sss.pgh.pa.us> writes:
>
>> Greg Stark <gsstark@mit.edu> writes:
>> > "Jesper K. Pedersen" <jkp@solnet.homeip.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:

	I guess this depends on the smartness of the language's client library.
	psycopg2 on python happily converts pg's types to and from python's  
native types (bool, int, datetime, arrays of these,  etc...). All types  
are supported except GIST stuff like polygons (but you can write a type  
converter for these). Never ever quote an argument again ! Life is good.

>>> DB.execute("SELECT (1=1)::bool, (1=0)::bool"); DB.fetchone()
(True, False)
>>> DB.execute("SELECT '{1,2,3,4}'::INTEGER[]"); DB.fetchone()
([1, 2, 3, 4],)
>>> DB.execute("SELECT '{1,2,3,4}'::NUMERIC[]"); DB.fetchone()
([Decimal("1"), Decimal("2"), Decimal("3"), Decimal("4")],)



view thread (10+ messages)  latest in thread

Message-ID: <op.s3vn28xdcigqcu@apollo13>
Permalink:  ../op.s3vn28xdcigqcu@apollo13/
Also on:    postgresql.org/message-id/op.s3vn28xdcigqcu@apollo13

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: lists@peufeu.com
  Subject: Re: How to implement Microsoft Access boolean (YESNO)
  In-Reply-To: <op.s3vn28xdcigqcu@apollo13>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox