Skip to content

Commit

Permalink
Add copying columns into top object
Browse files Browse the repository at this point in the history
Seems,  that it is because of DBIC::ResultSourceProxy::Table::table().

Looks like columns created,  but not copied into result class:

package D;
use base qw/ A B C /;

__PACKAGE__->table('tbl');

D will have only columns from A.

Columns from B and C will not copied into D.
  • Loading branch information
dim0xff committed Dec 27, 2013
1 parent 52092df commit 4ff0951
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
blib
inc
*.swp
Binary file modified db/db.db
Binary file not shown.
2 changes: 2 additions & 0 deletions lib/DB/Result/Realty/Apartment.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package DB::Result::Realty::Apartment;

use base qw/DB::Result::Realty/;

sub table { shift->next::method(@_) }

__PACKAGE__->table('__virtual__');

__PACKAGE__->add_columns(qw/ square rooms floor /);
Expand Down
11 changes: 11 additions & 0 deletions lib/DB/Result/Realty/Rent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ package DB::Result::Realty::Rent;

use base qw/DBIx::Class::Core/;

sub table {
my $class = shift;

$class->next::method(@_);

if ( $class ne __PACKAGE__ ) {
my $columns = __PACKAGE__->result_source_instance->_columns || {};
$class->add_columns( %{$columns} );
}
}

__PACKAGE__->table('__virtual__');

__PACKAGE__->add_columns(qw/ min_rent_period price_per_month /);
Expand Down
11 changes: 11 additions & 0 deletions lib/DB/Result/Realty/Sell.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ package DB::Result::Realty::Sell;

use base qw/DBIx::Class::Core/;

sub table {
my $class = shift;

$class->next::method(@_);

if ( $class ne __PACKAGE__ ) {
my $columns = __PACKAGE__->result_source_instance->_columns || {};
$class->add_columns( %{$columns} );
}
}

__PACKAGE__->table('__virtual__');

__PACKAGE__->add_columns(qw/ price_per_meter /);
Expand Down

0 comments on commit 4ff0951

Please sign in to comment.