Re: Inflate a boolean

[prev] [thread] [next] [Date index for 2005/02/20]

From: Johan Lindstrom
Subject: Re: Inflate a boolean
Date: 22:47 on 20 Feb 2005
At 23:24 2005-02-20, Ofer Nave wrote:
>3) (the missing case) So if you just want to convert the value to another 
>non-object value upon load... what do you do?  Is there a solution 
>involving triggers that I'm overlooking?

How about something like:
(untested, but adapted from what I use to numify values):

sub bool2yesno {
     my ($self, $name) = @_;
     $self->{$name} = $self->{$name} ? "Yes" : "No";
}
__PACKAGE__->add_trigger(select  => sub { my $self = shift;
     $self->bool2yesno("your_column_i_forgot_what_it_was_called");
});


>>But, most of the time, if you really want "yes" and "no", store those
>>in your database, not 1 and 0.
>>
>That is entirely subjective, and most definitely poor design (in my 
>opinion) in many cases.

Me too. Possibly there would be a value table for that to achieve 3NF.


/J

-------- ------ ---- --- -- --  --  -     -     -        -          -
Johan Lindström    Sourcerer @ Boss Casinos   johanl AT DarSerMan.com

Latest bookmark: "TCP Connection Passing"
http://tcpcp.sourceforge.net/
dmoz: /Computers/Programming/Languages/JavaScript/ 12

(message missing)

Inflate a boolean
adtim 09:08 on 20 Feb 2005

Re: Inflate a boolean
Ofer Nave 09:22 on 20 Feb 2005

Re: Inflate a boolean
Tony Bowden 09:44 on 20 Feb 2005

Re: Inflate a boolean
a.d.tim 10:35 on 20 Feb 2005

Re: Inflate a boolean
Tony Bowden 11:15 on 20 Feb 2005

Re[2]: Inflate a boolean
a.d.tim 12:37 on 20 Feb 2005

Re: Inflate a boolean
Perrin Harkins 21:15 on 20 Feb 2005

Re: Inflate a boolean
Ofer Nave 21:40 on 20 Feb 2005

Re: Inflate a boolean
Tony Bowden 22:07 on 20 Feb 2005

Re: Inflate a boolean
Ofer Nave 22:24 on 20 Feb 2005

Re: Inflate a boolean
Johan Lindstrom 22:47 on 20 Feb 2005

Re: Inflate a boolean
Tony Bowden 23:35 on 20 Feb 2005

Re: Inflate a boolean
Johan Lindstrom 00:20 on 21 Feb 2005

Re: Inflate a boolean
Tony Bowden 09:31 on 21 Feb 2005

Re: Inflate a boolean
=?ISO-8859-1?Q?Ask_Bj=F8rn_Hansen?= 21:25 on 21 Feb 2005

Generated at 12:48 on 22 Feb 2005 by mariachi v0.52