Re: [CDBI] How do you get the raw db value of a column rather than inflated object

[prev] [thread] [next] [Date index for 2006/02/13]

From: Peter Speltz
Subject: Re: [CDBI] How do you get the raw db value of a column rather than inflated object
Date: 15:37 on 13 Feb 2006
On 2/11/06, Bill Moseley <moseley@xxxx.xxx> wrote:
> On Sat, Feb 11, 2006 at 03:16:58PM -0600, Peter Speltz wrote:
> > On 2/11/06, Bill Moseley <moseley@xxxx.xxx> wrote:
> > > On Sat, Feb 11, 2006 at 06:57:32AM -0600, Peter Speltz wrote:
> > >
> > >   $object->my_column->id
> >
> >
> > Problem with that is you have to know you are dealing with an inflated
> > column and also a CDBI object in order to accurately get at the raw
> > value.   Has_a s can be inflated to any object.  I could call deflate
> > explicitly but it is not documented how to do that and  I cant remeber
> > if it is possible. I posted a while back asking. Need to search for
> > that thread.
>
> I'm curious.  Why do you need the raw column value in addition to the
> inflated value?
>

dont need it in addition.  I just need the raw value to edit. The
routine that  makes inputs for editting is setting  stringified
objects as the values for the input boxes rather than the actual  raw
column value. You can see how this is trouble when you want to edit a
datetime and end up with "Tues Nov. 3, 1998" in the input box.  Indeed
 I should have a better interface for editing date times yet but this
is just and example. It is a general problem.  The general solution i
found is just to use the deflate method or deflate the default class
dbi way. I wish
CDBI set a deflate method explicitly in metadata if you do not. That
would be nice.

if ($inflated_obj->can ($meta->{args}{deflate}) { # call it }

> I wonder if you could do something like this in your base class:
>
> <untested>
>
> sub _attribute_store {
>     my $self =3D shift;
>     my $vals   =3D @_ =3D=3D 1 ? $_[0] : {@_};
>     for my $key ( keys %$vals ) {
>         next if ref $vals->{$key};
>         $self->{$key . '_raw'} =3D $vals->{$key};
>     }
>     $self->SUPER::_attribute_store( @_ );
>
> }

Not a bad idea.

thanks.

>
> </untested>
>
> The you would ask for
>
>     my $value =3D $object->{my_column_raw};
>
>
>
>
>
>
> --
> Bill Moseley
> moseley@xxxx.xxx
>
>


--
pjs

_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

(message missing)

Re: [CDBI] How do you get the raw db value of a column rather than inflated object
Peter Speltz 15:37 on 13 Feb 2006

Generated at 10:41 on 18 Feb 2006 by mariachi v0.52