[Dbix-class] Adding columns 'on the fly'

Dan Richman dan at danrichman.com
Tue Feb 26 13:37:17 GMT 2008


Is it possible to select columns without actually adding those columns  
to the schema modules?

In other words:

while (my $obj = $rs->next) {
     my $data = $obj->Foo->my_column;
}

Is there a way to grab "my_column" without actually adding it to the  
schema?  I ask because in this case, "Foo" might or might not have a  
certain column.

I tried doing it this way ("on the fly");
$schema->source('Foo')->add_column(qw/ my_column /);
$schema->class('Foo')->add_column(qw/ my_column /);

But I found that mod_perl "remembered" the values and would throw  
errors if I re-instantiated the schema later, for a different database.

Any ideas?

Thanks in advance!







More information about the DBIx-Class mailing list