| ... | ... | 
                  @@ -1,5 +1,5 @@  | 
              
| 1 | 1 | 
                  0.1710  | 
              
| 2 | 
                  - - Fixed fisrt where clause failed.  | 
              |
| 2 | 
                  + - Fixed fisrt executed where clause failed in some condition.  | 
              |
| 3 | 3 | 
                  0.1709  | 
              
| 4 | 4 | 
                  - fixed named placeholder bug and added escape syntax  | 
              
| 5 | 5 | 
                  0.1708  | 
              
| ... | ... | 
                  @@ -448,7 +448,7 @@ sub execute {
                 | 
              
| 448 | 448 | 
                  # Result  | 
              
| 449 | 449 | 
                  my $result = $self->result_class->new(  | 
              
| 450 | 450 | 
                  sth => $sth,  | 
              
| 451 | 
                  - filters => $self->filters,  | 
              |
| 451 | 
                  + dbi => $self,  | 
              |
| 452 | 452 | 
                               default_filter => $self->{default_in_filter},
                 | 
              
| 453 | 453 | 
                               filter => $filter->{in} || {},
                 | 
              
| 454 | 454 | 
                               end_filter => $filter->{end} || {},
                 | 
              
| ... | ... | 
                  @@ -1073,16 +1073,7 @@ sub update_param {
                 | 
              
| 1073 | 1073 | 
                  return $tag;  | 
              
| 1074 | 1074 | 
                  }  | 
              
| 1075 | 1075 | 
                   | 
              
| 1076 | 
                  -sub where {
                 | 
              |
| 1077 | 
                  - my $self = shift;  | 
              |
| 1078 | 
                  -  | 
              |
| 1079 | 
                  - # Create where  | 
              |
| 1080 | 
                  - return DBIx::Custom::Where->new(  | 
              |
| 1081 | 
                  - quote => $self->_quote,  | 
              |
| 1082 | 
                  - dbi => $self,  | 
              |
| 1083 | 
                  - @_  | 
              |
| 1084 | 
                  - );  | 
              |
| 1085 | 
                  -}  | 
              |
| 1076 | 
                  +sub where { DBIx::Custom::Where->new(dbi => shift, @_) }
                 | 
              |
| 1086 | 1077 | 
                   | 
              
| 1087 | 1078 | 
                   sub _create_query {
                 | 
              
| 1088 | 1079 | 
                   | 
              
| ... | ... | 
                  @@ -5,9 +5,8 @@ use overload  | 
              
| 5 | 5 | 
                     '""'     => sub { shift->to_string },
                 | 
              
| 6 | 6 | 
                  fallback => 1;  | 
              
| 7 | 7 | 
                   | 
              
| 8 | 
                  -  | 
              |
| 9 | 
                  -has orders => sub { [] },
                 | 
              |
| 10 | 
                  - dbi => '';  | 
              |
| 8 | 
                  +has 'dbi',  | 
              |
| 9 | 
                  +    orders => sub { [] };
                 | 
              |
| 11 | 10 | 
                   | 
              
| 12 | 11 | 
                   sub prepend {
                 | 
              
| 13 | 12 | 
                  my $self = shift;  | 
              
| ... | ... | 
                  @@ -57,9 +56,15 @@ DBIx::Custom::Order - Order by EXPERIMENTAL  | 
              
| 57 | 56 | 
                       $order->prepend('title', 'author desc');
                 | 
              
| 58 | 57 | 
                  my $order_by = "$order";  | 
              
| 59 | 58 | 
                   | 
              
| 60 | 
                  -  | 
              |
| 61 | 59 | 
                  =head1 ATTRIBUTES  | 
              
| 62 | 60 | 
                   | 
              
| 61 | 
                  +=head2 C<dbi>  | 
              |
| 62 | 
                  +  | 
              |
| 63 | 
                  + my $dbi = $order->dbi;  | 
              |
| 64 | 
                  + $order = $order->dbi($dbi);  | 
              |
| 65 | 
                  +  | 
              |
| 66 | 
                  +L<DBIx::Custom> object.  | 
              |
| 67 | 
                  +  | 
              |
| 63 | 68 | 
                  =head2 C<orders>  | 
              
| 64 | 69 | 
                   | 
              
| 65 | 70 | 
                  my $orders = $result->orders;  | 
              
| ... | ... | 
                  @@ -4,7 +4,7 @@ use Object::Simple -base;  | 
              
| 4 | 4 | 
                  use Carp 'croak';  | 
              
| 5 | 5 | 
                  use DBIx::Custom::Util qw/_array_to_hash _subname/;  | 
              
| 6 | 6 | 
                   | 
              
| 7 | 
                  -has [qw/filters sth/],  | 
              |
| 7 | 
                  +has [qw/dbi sth/],  | 
              |
| 8 | 8 | 
                       stash => sub { {} };
                 | 
              
| 9 | 9 | 
                   | 
              
| 10 | 10 | 
                  *all = \&fetch_hash_all;  | 
              
| ... | ... | 
                  @@ -25,8 +25,8 @@ sub filter {
                 | 
              
| 25 | 25 | 
                  && ref $fname ne 'CODE')  | 
              
| 26 | 26 | 
                               {
                 | 
              
| 27 | 27 | 
                                 croak qq{Filter "$fname" is not registered" } . _subname
                 | 
              
| 28 | 
                  -                unless exists $self->filters->{$fname};
                 | 
              |
| 29 | 
                  -              $filter->{$column} = $self->filters->{$fname};
                 | 
              |
| 28 | 
                  +                unless exists $self->dbi->filters->{$fname};
                 | 
              |
| 29 | 
                  +              $filter->{$column} = $self->dbi->filters->{$fname};
                 | 
              |
| 30 | 30 | 
                  }  | 
              
| 31 | 31 | 
                  }  | 
              
| 32 | 32 | 
                   | 
              
| ... | ... | 
                  @@ -238,9 +238,9 @@ sub type_rule {
                 | 
              
| 238 | 238 | 
                                   my $fname = $type_rule->{"from$i"}{$data_type};
                 | 
              
| 239 | 239 | 
                                   if (defined $fname && ref $fname ne 'CODE') {
                 | 
              
| 240 | 240 | 
                                       croak qq{Filter "$fname" is not registered" } . _subname
                 | 
              
| 241 | 
                  -                      unless exists $self->filters->{$fname};
                 | 
              |
| 241 | 
                  +                      unless exists $self->dbi->filters->{$fname};
                 | 
              |
| 242 | 242 | 
                   | 
              
| 243 | 
                  -                    $type_rule->{"from$i"}{$data_type} = $self->filters->{$fname};
                 | 
              |
| 243 | 
                  +                    $type_rule->{"from$i"}{$data_type} = $self->dbi->filters->{$fname};
                 | 
              |
| 244 | 244 | 
                  }  | 
              
| 245 | 245 | 
                  }  | 
              
| 246 | 246 | 
                  }  | 
              
| ... | ... | 
                  @@ -307,8 +307,8 @@ sub end_filter {
                 | 
              
| 307 | 307 | 
                  && ref $fname ne 'CODE')  | 
              
| 308 | 308 | 
                               {
                 | 
              
| 309 | 309 | 
                                 croak qq{Filter "$fname" is not registered" } . _subname
                 | 
              
| 310 | 
                  -                unless exists $self->filters->{$fname};
                 | 
              |
| 311 | 
                  -              $end_filter->{$column} = $self->filters->{$fname};
                 | 
              |
| 310 | 
                  +                unless exists $self->dbi->filters->{$fname};
                 | 
              |
| 311 | 
                  +              $end_filter->{$column} = $self->dbi->filters->{$fname};
                 | 
              |
| 312 | 312 | 
                  }  | 
              
| 313 | 313 | 
                  }  | 
              
| 314 | 314 | 
                           $self->{end_filter} = {%{$self->end_filter}, %$end_filter};
                 | 
              
| ... | ... | 
                  @@ -341,8 +341,8 @@ sub default_filter {
                 | 
              
| 341 | 341 | 
                  }  | 
              
| 342 | 342 | 
                           else {
                 | 
              
| 343 | 343 | 
                               croak qq{Filter "$fname" is not registered}
                 | 
              
| 344 | 
                  -              unless exists $self->filters->{$fname};
                 | 
              |
| 345 | 
                  -            $self->{default_filter} = $self->filters->{$fname};
                 | 
              |
| 344 | 
                  +              unless exists $self->dbi->filters->{$fname};
                 | 
              |
| 345 | 
                  +            $self->{default_filter} = $self->dbi->filters->{$fname};
                 | 
              |
| 346 | 346 | 
                  }  | 
              
| 347 | 347 | 
                  return $self;  | 
              
| 348 | 348 | 
                  }  | 
              
| ... | ... | 
                  @@ -390,12 +390,12 @@ DBIx::Custom::Result - Result of select statement  | 
              
| 390 | 390 | 
                   | 
              
| 391 | 391 | 
                  =head1 ATTRIBUTES  | 
              
| 392 | 392 | 
                   | 
              
| 393 | 
                  -=head2 C<filters>  | 
              |
| 393 | 
                  +=head2 C<dbi>  | 
              |
| 394 | 394 | 
                   | 
              
| 395 | 
                  - my $filters = $result->filters;  | 
              |
| 396 | 
                  - $result = $result->filters(\%filters);  | 
              |
| 395 | 
                  + my $dbi = $result->dbi;  | 
              |
| 396 | 
                  + $result = $result->dbi($dbi);  | 
              |
| 397 | 397 | 
                   | 
              
| 398 | 
                  -Filters.  | 
              |
| 398 | 
                  +L<DBIx::Custom> object.  | 
              |
| 399 | 399 | 
                   | 
              
| 400 | 400 | 
                  =head2 C<sth>  | 
              
| 401 | 401 | 
                   | 
              
| ... | ... | 
                  @@ -9,7 +9,7 @@ use overload '""' => sub { shift->to_string }, fallback => 1;
                 | 
              
| 9 | 9 | 
                  # Carp trust relationship  | 
              
| 10 | 10 | 
                  push @DBIx::Custom::CARP_NOT, __PACKAGE__;  | 
              
| 11 | 11 | 
                   | 
              
| 12 | 
                  -has [qw/dbi param quote/],  | 
              |
| 12 | 
                  +has [qw/dbi param/],  | 
              |
| 13 | 13 | 
                       clause => sub { [] };
                 | 
              
| 14 | 14 | 
                   | 
              
| 15 | 15 | 
                   sub new {
                 | 
              
| ... | ... | 
                  @@ -106,7 +106,7 @@ sub _parse {
                 | 
              
| 106 | 106 | 
                   | 
              
| 107 | 107 | 
                  # Remove quote  | 
              
| 108 | 108 | 
                  my $column = $columns->[0];  | 
              
| 109 | 
                  -        if (my $q = $self->quote) {
                 | 
              |
| 109 | 
                  +        if (my $q = $self->dbi->_quote) {
                 | 
              |
| 110 | 110 | 
                  $q = quotemeta($q);  | 
              
| 111 | 111 | 
                  $column =~ s/[$q]//g;  | 
              
| 112 | 112 | 
                  }  | 
              
| ... | ... | 
                  @@ -15,13 +15,15 @@ BEGIN {
                 | 
              
| 15 | 15 | 
                       use_ok('DBIx::Custom::Result');
                 | 
              
| 16 | 16 | 
                  }  | 
              
| 17 | 17 | 
                   | 
              
| 18 | 
                  +use DBIx::Custom;  | 
              |
| 19 | 
                  +  | 
              |
| 18 | 20 | 
                   sub test { print "# $_[0]\n" }
                 | 
              
| 19 | 21 | 
                   | 
              
| 20 | 22 | 
                   sub query {
                 | 
              
| 21 | 23 | 
                  my ($dbh, $sql) = @_;  | 
              
| 22 | 24 | 
                  my $sth = $dbh->prepare($sql);  | 
              
| 23 | 25 | 
                  $sth->execute;  | 
              
| 24 | 
                  - return DBIx::Custom::Result->new(sth => $sth);  | 
              |
| 26 | 
                  + return DBIx::Custom::Result->new(dbi => DBIx::Custom->new, sth => $sth);  | 
              |
| 25 | 27 | 
                  }  | 
              
| 26 | 28 | 
                   | 
              
| 27 | 29 | 
                  my $dbh;  | 
              
| ... | ... | 
                  @@ -141,14 +143,14 @@ is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]);
                 | 
              
| 141 | 143 | 
                   | 
              
| 142 | 144 | 
                  test 'fetch filter';  | 
              
| 143 | 145 | 
                  $result = query($dbh, $sql);  | 
              
| 144 | 
                  -$result->filters({three_times => sub { $_[0] * 3}});
                 | 
              |
| 146 | 
                  +$result->dbi->filters({three_times => sub { $_[0] * 3}});
                 | 
              |
| 145 | 147 | 
                   $result->filter({key1 => 'three_times'});
                 | 
              
| 146 | 148 | 
                   | 
              
| 147 | 149 | 
                  $rows = $result->fetch_all;  | 
              
| 148 | 150 | 
                  is_deeply($rows, [[3, 2], [9, 4]], "array");  | 
              
| 149 | 151 | 
                   | 
              
| 150 | 152 | 
                  $result = query($dbh, $sql);  | 
              
| 151 | 
                  -$result->filters({three_times => sub { $_[0] * 3}});
                 | 
              |
| 153 | 
                  +$result->dbi->filters({three_times => sub { $_[0] * 3}});
                 | 
              |
| 152 | 154 | 
                   $result->filter({key1 => 'three_times'});
                 | 
              
| 153 | 155 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 154 | 156 | 
                   is_deeply($rows, [{key1 => 3, key2 => 2}, {key1 => 9, key2 => 4}], "hash");
                 |