Refactor ::DBIHacks::_extract_fixed_condition_columns (sequel to 8d005ad9)
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / ResultSourceProxy.pm
CommitLineData
75d07914 1package # hide from PAUSE
c0e7b4e5 2 DBIx::Class::ResultSourceProxy;
b98e75f6 3
4use strict;
5use warnings;
6
7use base qw/DBIx::Class/;
93405cf0 8use Scalar::Util qw/blessed/;
a93c65f2 9use Sub::Name qw/subname/;
10use namespace::clean;
b98e75f6 11
a93c65f2 12__PACKAGE__->mk_group_accessors('inherited_ro_instance' => 'source_name');
13
14sub get_inherited_ro_instance { shift->get_inherited(@_) }
b98e75f6 15
93405cf0 16sub set_inherited_ro_instance {
a93c65f2 17 my $self = shift;
93405cf0 18
a93c65f2 19 $self->throw_exception ("Cannot set @{[shift]} on an instance")
20 if blessed $self;
93405cf0 21
a93c65f2 22 $self->set_inherited(@_);
93405cf0 23}
24
5ac6a044 25
b98e75f6 26sub add_columns {
27 my ($class, @cols) = @_;
1f23a877 28 my $source = $class->result_source_instance;
29 $source->add_columns(@cols);
30 foreach my $c (grep { !ref } @cols) {
157ce0cf 31 # If this is an augment definition get the real colname.
32 $c =~ s/^\+//;
33
1f23a877 34 $class->register_column($c => $source->column_info($c));
35 }
b98e75f6 36}
37
a93c65f2 38sub add_column { shift->add_columns(@_) }
002a359a 39
002a359a 40
a93c65f2 41sub add_relationship {
42 my ($class, $rel, @rest) = @_;
43 my $source = $class->result_source_instance;
44 $source->add_relationship($rel => @rest);
45 $class->register_relationship($rel => $source->relationship_info($rel));
bc0c9800 46}
47
b98e75f6 48
a93c65f2 49# legacy resultset_class accessor, seems to be used by cdbi only
50sub iterator_class { shift->result_source_instance->resultset_class(@_) }
a83cdbf2 51
a93c65f2 52for my $method_to_proxy (qw/
53 source_info
54 result_class
55 resultset_class
56 resultset_attributes
bc0c9800 57
a93c65f2 58 columns
59 has_column
034d0be4 60
a93c65f2 61 remove_column
62 remove_columns
87f0da6a 63
a93c65f2 64 column_info
52416317 65 columns_info
a93c65f2 66 column_info_from_storage
1bc0b925 67
a93c65f2 68 set_primary_key
69 primary_columns
89170201 70 sequence
1bc0b925 71
a93c65f2 72 add_unique_constraint
73 add_unique_constraints
8c49f629 74
a93c65f2 75 unique_constraints
76 unique_constraint_names
77 unique_constraint_columns
8c49f629 78
a93c65f2 79 relationships
80 relationship_info
81 has_relationship
82/) {
83 no strict qw/refs/;
84 *{__PACKAGE__."::$method_to_proxy"} = subname $method_to_proxy => sub {
85 shift->result_source_instance->$method_to_proxy (@_);
86 };
8c49f629 87}
88
b98e75f6 891;