[Dbix-class] a function as a column
Erik Colson
eco at ecocode.net
Tue Feb 10 09:53:34 GMT 2015
Hi all,
I have a table with numeric fields a en b. So the Resultsource declaration is
__PACKAGE__->add_columns( 'a' => { is_numeric => 1 },
'b' => { is_numeric => 1 }, )
In the Resultsource class I want to add sub c as follows:
sub c {
my $self = shift;
return $self->a + $self->b
}
Now how can I use c as a column ? This is what I need:
my $selection = $rs->search({}, { columns => [qw /a b c/] }) ;
which would return a,b,c for all rows in the table, keeping the function
c hidden behind the name of a column.
Any hints ?
--
erik colson
More information about the DBIx-Class
mailing list