[Dbix-class] Reusing defined columns (inheritance?)

Dmitry Latin dim0xff at gmail.com
Fri Dec 27 09:42:30 GMT 2013


Hello!

I've asked this question yesterday on IRC, but didn't get the answer.


The problem.
I have a lot of tables, which have general columns (id, creation date, status, 
etc).
Also, some of them have their own columns, another tables have their own 
columns (which are different from previous group of tables).
I want to create some base RS with general columns, and also create some 
"extension" for each group with needed columns. And then in result class I 
want to mix columns from "base" and "extension".

It is like inheritance in object oriented programming:

A <- B <- D
          |
     C <--+

Here D is inherited from C and B (which is inherited from A)
So, probably, D will have all fields from A, B and C.

Is there easy way to make this extension? (I need to mix columns which are 
defined in "base" and in "extension").


I made an example.
Here is tables definition: 
https://github.com/dim0xff/dbic_inheritance/blob/master/db/db.sql
Here is full example: https://github.com/dim0xff/dbic_inheritance

When I have table D (A <- B <- D), then every thing is working fine: 
https://github.com/dim0xff/dbic_inheritance/blob/master/lib/DB/Result/Realty/House/Sell.pm

But when I add another inheritance to D ( A <- B <- D -> C : 
https://github.com/dim0xff/dbic_inheritance/blob/master/lib/DB/Result/Realty/Apartment/Sell.pm), 
then I have the problem: RS doesn't have columns, which are defined in 
DB::Result::Realty::Sell.

-- 
//wbr, Dmitry L.



More information about the DBIx-Class mailing list