- fixed bug that DBIx::Custom::Model count method...
...don't receive model's
| ... | ... |
@@ -1,4 +1,8 @@ |
| 1 |
+0.2102 |
|
| 2 |
+ - fixed bug that DBIx::Custom::Model count method don't receive model's |
|
| 3 |
+ attribute |
|
| 1 | 4 |
0.2101 |
| 5 |
+ - fixed small default_bind_filter bug |
|
| 2 | 6 |
- micro optimization |
| 3 | 7 |
- select method can receive odd number argument. In that case first argument |
| 4 | 8 |
is column option. |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
package DBIx::Custom; |
| 2 | 2 |
use Object::Simple -base; |
| 3 | 3 |
|
| 4 |
-our $VERSION = '0.2101'; |
|
| 4 |
+our $VERSION = '0.2102'; |
|
| 5 | 5 |
use 5.008001; |
| 6 | 6 |
|
| 7 | 7 |
use Carp 'croak'; |
| ... | ... |
@@ -499,8 +499,8 @@ sub execute {
|
| 499 | 499 |
# Execute |
| 500 | 500 |
my $sth = $query->{sth};
|
| 501 | 501 |
my $affected; |
| 502 |
- if (!$query->{duplicate} && $type_rule_off && !keys %$filter &&
|
|
| 503 |
- !$opt{bind_type} && !$opt{type} && !$ENV{DBIX_CUSTOM_DEBUG})
|
|
| 502 |
+ if (!$query->{duplicate} && $type_rule_off && !keys %$filter && !$self->{default_out_filter}
|
|
| 503 |
+ && !$opt{bind_type} && !$opt{type} && !$ENV{DBIX_CUSTOM_DEBUG})
|
|
| 504 | 504 |
{
|
| 505 | 505 |
eval { $affected = $sth->execute(map { $param->{$_} } @{$query->{columns}}) };
|
| 506 | 506 |
} |
| ... | ... |
@@ -52,7 +52,9 @@ for my $method (@methods) {
|
| 52 | 52 |
my @select_attrs = qw/join/; |
| 53 | 53 |
if ($method eq 'insert') { push @attrs, @insert_attrs }
|
| 54 | 54 |
elsif ($method eq 'update') { push @attrs, @update_attrs }
|
| 55 |
- elsif (index($method, 'select') != -1) { push @attrs, @select_attrs }
|
|
| 55 |
+ elsif (index($method, 'select') != -1 || $method eq 'count') {
|
|
| 56 |
+ push @attrs, @select_attrs |
|
| 57 |
+ } |
|
| 56 | 58 |
|
| 57 | 59 |
for my $attr (@attrs) {
|
| 58 | 60 |
$code .= "exists \$self->{$attr} ? ($attr => \$self->{$attr}) : (),";
|
| ... | ... |
@@ -489,8 +489,14 @@ $dbi->insert({$key1 => 1, $key2 => 2}, table => $table1, filter => {$key1 => 'th
|
| 489 | 489 |
$result = $dbi->execute("select * from $table1");
|
| 490 | 490 |
$rows = $result->all; |
| 491 | 491 |
is_deeply($rows, [{$key1 => 3, $key2 => 4}], "filter");
|
| 492 |
+$dbi->delete_all(table => $table1); |
|
| 493 |
+$dbi->insert({$key1 => 1, $key2 => 2}, table => $table1);
|
|
| 494 |
+$result = $dbi->execute("select * from $table1");
|
|
| 495 |
+$rows = $result->all; |
|
| 496 |
+is_deeply($rows, [{$key1 => 2, $key2 => 4}], "filter");
|
|
| 492 | 497 |
$dbi->default_bind_filter(undef); |
| 493 | 498 |
|
| 499 |
+ |
|
| 494 | 500 |
eval { $dbi->execute("drop table $table1") };
|
| 495 | 501 |
$dbi->execute($create_table1); |
| 496 | 502 |
$dbi->insert({$key1 => 1, $key2 => 2}, table => $table1, append => ' ');
|
| ... | ... |
@@ -4557,4 +4563,16 @@ is($dbi->count(table => $table1, where => {$key2 => 2}), 1);
|
| 4557 | 4563 |
$model = $dbi->create_model(table => $table1); |
| 4558 | 4564 |
is($model->count, 2); |
| 4559 | 4565 |
|
| 4566 |
+eval { $dbi->execute("drop table $table1") };
|
|
| 4567 |
+eval { $dbi->execute("drop table $table2") };
|
|
| 4568 |
+$dbi->execute($create_table1); |
|
| 4569 |
+$dbi->execute($create_table2); |
|
| 4570 |
+$model = $dbi->create_model(table => $table1, primary_key => $key1); |
|
| 4571 |
+$model->insert({$key1 => 1, $key2 => 2});
|
|
| 4572 |
+$model = $dbi->create_model(table => $table2, primary_key => $key1, |
|
| 4573 |
+ join => ["left outer join $table1 on $table2.$key1 = $table1.$key1"]); |
|
| 4574 |
+$model->insert({$key1 => 1, $key3 => 3});
|
|
| 4575 |
+is($model->count(id => 1), 1); |
|
| 4576 |
+is($model->count(where => {"$table2.$key3" => 3}), 1);
|
|
| 4577 |
+ |
|
| 4560 | 4578 |
1; |