Virtual / Volatile DBIx Class Row Columns

Is it possible to add columns to a DBIx :: Class :: Row object that are virtual since they are not stored in the database? I'm looking for functionality like Rose :: DB :: Object provides via its non-persistent columns http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Metadata.pm#nonpersistent_columns

+3


source to share


2 answers


Have you tried adding methods to result classes in your schema? This can lead you to the same place. The methods added cannot be used in -> search and will not return in -> get_columns, but depending on your use case, this may be sufficient.



+3


source


I just needed to watch it again as I need it. You may already have a solution, but for others who come here: https://metacpan.org/module/DBIx::Class::Manual::FAQ#Misc

Basically 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

      

+2


source







All Articles