Add automatic naming of unique constraints
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / ResultSourceProxy.pm
1 package # hide from PAUSE
2     DBIx::Class::ResultSourceProxy;
3
4 use strict;
5 use warnings;
6
7 use base qw/DBIx::Class/;
8
9 sub iterator_class  { shift->result_source_instance->resultset_class(@_) }
10 sub resultset_class { shift->result_source_instance->resultset_class(@_) }
11 sub source_name { shift->result_source_instance->source_name(@_) }
12
13 sub resultset_attributes {
14   shift->result_source_instance->resultset_attributes(@_);
15 }
16
17 sub add_columns {
18   my ($class, @cols) = @_;
19   my $source = $class->result_source_instance;
20   $source->add_columns(@cols);
21   foreach my $c (grep { !ref } @cols) {
22     $class->register_column($c => $source->column_info($c));
23   }
24 }
25
26 *add_column = \&add_columns;
27
28 sub has_column {
29   my ($self, $column) = @_;
30   return $self->result_source_instance->has_column($column);
31 }
32
33 sub column_info {
34   my ($self, $column) = @_;
35   return $self->result_source_instance->column_info($column);
36 }
37
38
39 sub columns {
40   return shift->result_source_instance->columns(@_);
41 }
42
43 sub remove_columns {
44   return shift->result_source_instance->remove_columns(@_);
45 }
46
47 *remove_column = \&remove_columns;
48
49 sub set_primary_key {
50   shift->result_source_instance->set_primary_key(@_);
51 }
52
53 sub primary_columns {
54   shift->result_source_instance->primary_columns(@_);
55 }
56
57 sub add_unique_constraint {
58   shift->result_source_instance->add_unique_constraint(@_);
59 }
60
61 sub unique_constraints {
62   shift->result_source_instance->unique_constraints(@_);
63 }
64
65 sub unique_constraint_names {
66   shift->result_source_instance->unique_constraint_names(@_);
67 }
68
69 sub unique_constraint_columns {
70   shift->result_source_instance->unique_constraint_columns(@_);
71 }
72
73 sub add_relationship {
74   my ($class, $rel, @rest) = @_;
75   my $source = $class->result_source_instance;
76   $source->add_relationship($rel => @rest);
77   $class->register_relationship($rel => $source->relationship_info($rel));
78 }
79
80 sub relationships {
81   shift->result_source_instance->relationships(@_);
82 }
83
84 sub relationship_info {
85   shift->result_source_instance->relationship_info(@_);
86 }
87
88 1;