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

Bill Moseley moseley at hank.org
Sat Feb 11 23:31:09 GMT 2006

On Sat, Feb 11, 2006 at 03:16:58PM -0600, Peter Speltz wrote:
> On 2/11/06, Bill Moseley <moseley at hank.org> 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?

I wonder if you could do something like this in your base class:


sub _attribute_store {
    my $self = shift;
    my $vals   = @_ == 1 ? $_[0] : {@_};
    for my $key ( keys %$vals ) {
        next if ref $vals->{$key};
        $self->{$key . '_raw'} = $vals->{$key};
    $self->SUPER::_attribute_store( @_ );



The you would ask for

    my $value = $object->{my_column_raw};

Bill Moseley
moseley at hank.org

More information about the ClassDBI mailing list