Commit | Line | Data |
c0e7b4e5 |
1 | package # hide from PAUSE |
2 | DBIx::Class::CDBICompat::ColumnCase; |
ea2e61bf |
3 | |
4 | use strict; |
5 | use warnings; |
75a23b3e |
6 | |
5e0eea35 |
7 | use base 'DBIx::Class'; |
8 | |
ea2e61bf |
9 | sub _register_column_group { |
10 | my ($class, $group, @cols) = @_; |
147dd158 |
11 | return $class->next::method($group => map lc, @cols); |
ea2e61bf |
12 | } |
13 | |
ec77fadc |
14 | sub add_columns { |
15 | my ($class, @cols) = @_; |
e570488a |
16 | return $class->result_source->add_columns(map lc, @cols); |
ec77fadc |
17 | } |
18 | |
12bbb339 |
19 | sub has_a { |
c79bd6e9 |
20 | my($self, $col, @rest) = @_; |
d4daee7b |
21 | |
c79bd6e9 |
22 | $self->_declare_has_a(lc $col, @rest); |
23 | $self->_mk_inflated_column_accessor($col); |
d4daee7b |
24 | |
c79bd6e9 |
25 | return 1; |
12bbb339 |
26 | } |
27 | |
b8e1e21f |
28 | sub has_many { |
29 | my ($class, $rel, $f_class, $f_key, @rest) = @_; |
de0ed7f1 |
30 | return $class->next::method( |
31 | $rel, |
32 | $f_class, |
33 | (ref($f_key) ? |
34 | $f_key : |
35 | lc($f_key||'') |
36 | ), |
37 | @rest |
38 | ); |
b8e1e21f |
39 | } |
40 | |
9f300b1b |
41 | sub get_inflated_column { |
12bbb339 |
42 | my ($class, $get, @rest) = @_; |
147dd158 |
43 | return $class->next::method(lc($get), @rest); |
12bbb339 |
44 | } |
45 | |
9f300b1b |
46 | sub store_inflated_column { |
12bbb339 |
47 | my ($class, $set, @rest) = @_; |
147dd158 |
48 | return $class->next::method(lc($set), @rest); |
12bbb339 |
49 | } |
50 | |
9f300b1b |
51 | sub set_inflated_column { |
12bbb339 |
52 | my ($class, $set, @rest) = @_; |
147dd158 |
53 | return $class->next::method(lc($set), @rest); |
ea2e61bf |
54 | } |
55 | |
510ca912 |
56 | sub get_column { |
ea2e61bf |
57 | my ($class, $get, @rest) = @_; |
147dd158 |
58 | return $class->next::method(lc($get), @rest); |
ea2e61bf |
59 | } |
60 | |
510ca912 |
61 | sub set_column { |
ea2e61bf |
62 | my ($class, $set, @rest) = @_; |
147dd158 |
63 | return $class->next::method(lc($set), @rest); |
510ca912 |
64 | } |
65 | |
66 | sub store_column { |
67 | my ($class, $set, @rest) = @_; |
147dd158 |
68 | return $class->next::method(lc($set), @rest); |
ea2e61bf |
69 | } |
70 | |
71 | sub find_column { |
72 | my ($class, $col) = @_; |
147dd158 |
73 | return $class->next::method(lc($col)); |
ea2e61bf |
74 | } |
75 | |
9387c904 |
76 | # _build_query |
77 | # |
78 | # Build a query hash for find, et al. Overrides Retrieve::_build_query. |
79 | |
80 | sub _build_query { |
81 | my ($self, $query) = @_; |
82 | |
83 | my %new_query; |
84 | $new_query{lc $_} = $query->{$_} for keys %$query; |
85 | |
86 | return \%new_query; |
87 | } |
88 | |
8da46543 |
89 | sub _deploy_accessor { |
90 | my($class, $name, $accessor) = @_; |
e60dc79f |
91 | |
8da46543 |
92 | return if $class->_has_custom_accessor($name); |
e60dc79f |
93 | |
8da46543 |
94 | $class->next::method(lc $name => $accessor); |
95 | return $class->next::method($name => $accessor); |
12bbb339 |
96 | } |
97 | |
8da46543 |
98 | |
12bbb339 |
99 | sub new { |
100 | my ($class, $attrs, @rest) = @_; |
101 | my %att; |
102 | $att{lc $_} = $attrs->{$_} for keys %$attrs; |
147dd158 |
103 | return $class->next::method(\%att, @rest); |
ea2e61bf |
104 | } |
105 | |
106 | 1; |