pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Markus Bertheau ☭ <twanger@bluetwanger.de>
To: Michael Glaesemann <grzm@myrealbox.com>
Cc: PostgreSQL <pgsql-sql@postgresql.org>
Subject: Re: 'true'::TEXT::BOOLEAN
Date: Fri, 03 Jun 2005 14:23:37 +0200
Message-ID: <1117801417.9816.28.camel@dicaprio.akademie1.de> (raw)
In-Reply-To: <3DCEDE55-9D4A-4F4E-8907-ADCC058A3398@myrealbox.com>
References: <Pine.LNX.4.44.0506031420340.23350-100000@matrix.gatewaynet.com>
	<1117799555.9816.24.camel@dicaprio.akademie1.de>
	<3DCEDE55-9D4A-4F4E-8907-ADCC058A3398@myrealbox.com>

This also bypasses the built in postgresql boolean literal parsing.

I think casting from text to boolean should be possible, and use the
same algorithm that's used when casting from "unknown" to boolean.

Markus

В Птн, 03/06/2005 в 21:14 +0900, Michael Glaesemann пишет:
> On Jun 3, 2005, at 8:52 PM, Markus Bertheau ☭ wrote:
> 
> > And I can't call it with a TEXT variable, because casting from TEXT to
> > BOOLEAN isn't possible.
> 
> 
> I'd be surprised if there weren't a some way to coerce the cast from  
> text to boolean, but you might want to just make a simple convenience  
> function in the interim:
> 
> test=# create or replace function text2bool (text)
>      returns boolean language sql as $$
> select case
>      when lower($1) = 'true'
>          then true
>      else false
>      end;
>      $$;
> CREATE FUNCTION
> 
> test=# select text2bool('true');
> text2bool
> -----------
> t
> (1 row)
> 
> test=# select text2bool('false');
> text2bool
> -----------
> f
> (1 row)
> 
> 
> Just an idea.
> 
> Michael Glaesemann
> grzm myrealbox com
-- 
Markus Bertheau ☭ <twanger@bluetwanger.de>




view thread (15+ messages)  latest in thread

Message-ID: <1117801417.9816.28.camel@dicaprio.akademie1.de>
Permalink:  ../1117801417.9816.28.camel@dicaprio.akademie1.de/
Also on:    postgresql.org/message-id/1117801417.9816.28.camel@dicaprio.akademie1.de

 · 

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: twanger@bluetwanger.de, grzm@myrealbox.com
  Subject: Re: 'true'::TEXT::BOOLEAN
  In-Reply-To: <1117801417.9816.28.camel@dicaprio.akademie1.de>

* 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