[Dbix-class] DynamicColumns

Karl Forner karl.forner at gmail.com
Mon Sep 17 21:20:23 GMT 2012


Hello dear DBICx users,

I am currently working on a project, and I suddenly realized that I should
have asked for your wise suggestions before
jumping into that maybe useless project.

The goal is to provide dynamic columns to dbix result objects. I was
inspired by the DBICx::VirtualColumns package, but I do not store any value
into the row object, just override methods that use user supplied callbacks
to get the value.

The overall intended usage is to provide some "view" columns that can be
transparently used as is they were actual columns, for instance by
CatalystX::ExtJS::REST
to provide a table view of the tables that incorporate the new columns.

To be more concrete, suppose that you have User table, with a foreign key
user_type_id on a UserType table (a lookup table).
You'd like your nice extjs grid automatically filled thanks to
CatalystX::ExtJS::REST to display a user_type column, because the
"user_type_id" column is not veru useful for your customers.

Using DBICx::DynamicColumns, you could tie the (new) method/column "type"
to $row->user_type()->name() for instance.

Another intended use is to provide accessors for another project that will
provide some optimized cache and useful accessors/checks for this kind of
Lookup tables.

I currently have a prototype that only works for one table, and that is
very hackish because I sometimes have to hide the dynamic columns, and so
wrap the methods that should not see those dynamic columns.

What do you think ??
Is-it a valid approach ?

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20120917/706=
6cbe8/attachment.htm


More information about the DBIx-Class mailing list