- select method column option [COLUMN, as => ALIAS...
...] format is DEPRECATED!
... | ... |
@@ -1,4 +1,6 @@ |
1 | 1 |
0.1701 |
2 |
+ - select method column option [COLUMN, as => ALIAS] format is DEPRECATED! |
|
3 |
+ changed to [COLUMN => ALIAS] |
|
2 | 4 |
- added EXPERIMENTAL DBIx::Custom::Result header method |
3 | 5 |
- added EXPERIMENTAL last_sql attribute method |
4 | 6 |
0.1700 |
... | ... |
@@ -814,9 +814,12 @@ sub select { |
814 | 814 |
$column = $self->column(%$column) if ref $column eq 'HASH'; |
815 | 815 |
} |
816 | 816 |
elsif (ref $column eq 'ARRAY') { |
817 |
- croak "Format must be [COLUMN, as => ALIAS] " . _subname |
|
818 |
- unless @$column == 3 && $column->[1] eq 'as'; |
|
819 |
- $column = join(' ', $column->[0], 'as', $q . $column->[2] . $q); |
|
817 |
+ if (@$column == 3 && $column->[1] eq 'as') { |
|
818 |
+ warn "[COLUMN, as => ALIAS] is DEPRECATED! use [COLUMN => ALIAS]"; |
|
819 |
+ splice @$column, 1, 1; |
|
820 |
+ } |
|
821 |
+ |
|
822 |
+ $column = join(' ', $column->[0], 'as', $q . $column->[1] . $q); |
|
820 | 823 |
} |
821 | 824 |
unshift @$tables, @{$self->_search_tables($column)}; |
822 | 825 |
push @sql, ($column, ','); |
... | ... |
@@ -2672,13 +2675,14 @@ This is expanded to the following one by using C<colomn> method. |
2672 | 2675 |
person.name as "person.name", |
2673 | 2676 |
person.age as "person.age" |
2674 | 2677 |
|
2675 |
-You can specify array of array reference. |
|
2678 |
+You can specify array of array reference, first argument is |
|
2679 |
+column name, second argument is alias. |
|
2676 | 2680 |
|
2677 | 2681 |
column => [ |
2678 |
- ['date(book.register_datetime)', as => 'book.register_date'] |
|
2682 |
+ ['date(book.register_datetime)' => 'book.register_date'] |
|
2679 | 2683 |
]; |
2680 | 2684 |
|
2681 |
-Alias is quoted and joined. |
|
2685 |
+Alias is quoted properly and joined. |
|
2682 | 2686 |
|
2683 | 2687 |
date(book.register_datetime) as "book.register_date" |
2684 | 2688 |
|
... | ... |
@@ -2190,14 +2190,14 @@ $result = $model->select_at( |
2190 | 2190 |
is_deeply($result->one, |
2191 | 2191 |
{key1 => 1, 'table2.key1' => 1}); |
2192 | 2192 |
|
2193 |
-eval{ |
|
2194 |
- $result = $model->select_at( |
|
2195 |
- column => [ |
|
2196 |
- ['table2.key1', asaaaa => 'table2.key1'] |
|
2197 |
- ] |
|
2198 |
- ); |
|
2199 |
-}; |
|
2200 |
-like($@, qr/COLUMN/); |
|
2193 |
+$result = $model->select_at( |
|
2194 |
+ column => [ |
|
2195 |
+ $model->mycolumn(['key1']), |
|
2196 |
+ ['table2.key1' => 'table2.key1'] |
|
2197 |
+ ] |
|
2198 |
+); |
|
2199 |
+is_deeply($result->one, |
|
2200 |
+ {key1 => 1, 'table2.key1' => 1}); |
|
2201 | 2201 |
|
2202 | 2202 |
test 'dbi method from model'; |
2203 | 2203 |
{ |