Is it possible to add columns to a DBIx::Class::Row object that are virtual in that they are not saved to the database? I am looking for functionality like Rose::DB::Object provides through its non-persistent columns http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Metadata.pm#nonpersistent_columns
DBIx Class Row virtual/non-persistent columns
414 Views Asked by Bestfoodnearme.com At
2
There are 2 best solutions below
0

I just had to look this up again as I had a need for it. You've probably got a solution already, but for others that come here looking: https://metacpan.org/module/DBIx::Class::Manual::FAQ#Misc
Basically either use Moose and create an attribute, or add something like this to your schema:
__PACKAGE__->mk_group_accessors('simple' => qw/non_column_data/); # must use simple group
Have you tried adding methods to the Result classes in your Schema? That might get you to the same place. The methods you add can't be used in ->search and won't be returned in ->get_columns, but depending on your use case, it may be enough.