- select method can receive odd number argument...
.... In that case first argument
... | ... |
@@ -1,4 +1,6 @@ |
1 | 1 |
0.2101 |
2 |
+ - select method can receive odd number argument. In that case first argument |
|
3 |
+ is column option. |
|
2 | 4 |
- fixed update_or_insert bug that when parameter don't contain any key-value |
3 | 5 |
this method throw exception. |
4 | 6 |
0.2100 |
... | ... |
@@ -892,7 +892,10 @@ sub register_filter { |
892 | 892 |
} |
893 | 893 |
|
894 | 894 |
sub select { |
895 |
- my ($self, %opt) = @_; |
|
895 |
+ my $self = shift; |
|
896 |
+ my $column = shift if @_ % 2; |
|
897 |
+ my %opt = @_; |
|
898 |
+ $opt{column} = $column if defined $column; |
|
896 | 899 |
|
897 | 900 |
# Options |
898 | 901 |
my $tables = ref $opt{table} eq 'ARRAY' ? $opt{table} |
... | ... |
@@ -2955,13 +2958,18 @@ Register filters, used by C<filter> option of many methods. |
2955 | 2958 |
=head2 C<select> |
2956 | 2959 |
|
2957 | 2960 |
my $result = $dbi->select( |
2958 |
- table => 'book', |
|
2959 | 2961 |
column => ['author', 'title'], |
2962 |
+ table => 'book', |
|
2960 | 2963 |
where => {author => 'Ken'}, |
2961 | 2964 |
); |
2962 | 2965 |
|
2963 | 2966 |
Execute select statement. |
2964 | 2967 |
|
2968 |
+You can pass odd number arguments. first argument is C<column>. |
|
2969 |
+This is EXPERIMENTAL. |
|
2970 |
+ |
|
2971 |
+ my $result = $dbi->select(['author', 'title'], table => 'book'); |
|
2972 |
+ |
|
2965 | 2973 |
B<OPTIONS> |
2966 | 2974 |
|
2967 | 2975 |
C<select> method use all of C<execute> method's options, |
... | ... |
@@ -267,6 +267,12 @@ $model = $dbi->create_model(table => $table1); |
267 | 267 |
$model->insert({$key1 => 1, $key2 => 2}); |
268 | 268 |
is_deeply($model->select->all, [{$key1 => 1, $key2 => 2}]); |
269 | 269 |
|
270 |
+eval { $dbi->execute("drop table $table1") }; |
|
271 |
+$dbi->execute($create_table1); |
|
272 |
+$model = $dbi->create_model(table => $table1); |
|
273 |
+$model->insert({$key1 => 1, $key2 => 2}); |
|
274 |
+is_deeply($model->select($key1)->all, [{$key1 => 1}]); |
|
275 |
+ |
|
270 | 276 |
test 'DBIx::Custom::Result test'; |
271 | 277 |
$dbi->delete_all(table => $table1); |
272 | 278 |
$dbi->insert({$key1 => 1, $key2 => 2}, table => $table1); |
... | ... |
@@ -1121,6 +1127,12 @@ $result = $dbi->select(table => 'table', where => {select => 1}); |
1121 | 1127 |
$rows = $result->all; |
1122 | 1128 |
is_deeply($rows, [{select => 2, update => 2}], "reserved word"); |
1123 | 1129 |
|
1130 |
+eval { $dbi->execute("drop table $table1") }; |
|
1131 |
+$dbi->execute($create_table1); |
|
1132 |
+$dbi->insert({$key1 => 1, $key2 => 2}, table => $table1); |
|
1133 |
+$row = $dbi->select($key1, table => $table1)->one; |
|
1134 |
+is_deeply($row, {$key1 => 1}); |
|
1135 |
+ |
|
1124 | 1136 |
test 'fetch filter'; |
1125 | 1137 |
eval { $dbi->execute("drop table $table1") }; |
1126 | 1138 |
$dbi->register_filter( |