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
Asked
Active
Viewed 400 times
2 Answers
3
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.

oalders
- 5,239
- 2
- 23
- 34
2
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

kbosak
- 2,132
- 1
- 13
- 16