If the calculation must be done on the database side (after your earlier comment), then use the temporary column idea that i suggested, together with some direct SQL. Assuming that you don't wish to search on the field, then something like the following should work:
my $rs = My::Schema->resultset('people');
my @columns_as = $rs->result_source->columns;
my @columns = map { "me.$_" } @columns_as;
my @people = $rs->search(
{ ... where conditions here ... },
{
select => [ @columns, \"me.first || ' ' || me.last" ], # scalar ref for direct SQL
as => [ @columns_as, 'full_name' ],
order_by => 'full_name',
... etc ...
}
);
# then
print $_->full_name."\n" foreach @people; # now set on the object...
It should theoretically be possible to just specify your additional select
and as
columns using +select
and +as
, but I was unable to get these to work properly (this was a year or so ago). Can't recall exactly why now...