Showing 3 changed files with 21 additions and 4 deletions
+1
Changes
... ...
@@ -1,4 +1,5 @@
1 1
 0.1653
2
+    - added experimental DBIx::Custom::Result remove_filter()
2 3
     - added experimental DBIx::Custom::Result remove_end_filter()
3 4
     - added experimental DBIx::Custom::Model insert_at()
4 5
     - added experimental insert_at()
+14
lib/DBIx/Custom/Result.pm
... ...
@@ -255,6 +255,14 @@ sub remove_end_filter {
255 255
     return $self;
256 256
 }
257 257
 
258
+sub remove_filter {
259
+    my $self = shift;
260
+    
261
+    $self->{filter} = {};
262
+    
263
+    return $self;
264
+}
265
+
258 266
 # Deprecated
259 267
 sub default_filter {
260 268
     my $self = shift;
... ...
@@ -442,6 +450,12 @@ L<DBIx::Custom>.
442 450
 
443 451
 Remove end filter.
444 452
 
453
+=head2 C<(experimental) remove_filter>
454
+
455
+    $result->remove_filter;
456
+
457
+Remove filter. End filter is not removed.
458
+
445 459
 =head2 C<(experimental) stash>
446 460
 
447 461
     my $stash = $result->stash;
+6 -4
t/dbix-custom-core-sqlite.t
... ...
@@ -875,16 +875,18 @@ $result->end_filter(key1 => undef);
875 875
 $row = $result->fetch_hash_first;
876 876
 is_deeply($row, {key1 => 1, key2 => 40}, 'apply_filter overwrite');
877 877
 
878
-test 'remove_end_filter';
878
+test 'remove_end_filter and remove_filter';
879 879
 $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
880 880
 $dbi->execute($CREATE_TABLE->{0});
881 881
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
882 882
 $result = $dbi->select(table => 'table1');
883
-$result->filter(key1 => sub { $_[0] * 2 }, key2 => sub { $_[0] * 4 });
884
-$row = $result->end_filter(key1 => sub { $_[0] * 3 }, key2 => sub { $_[0] * 5 })
883
+$row = $result
884
+       ->filter(key1 => sub { $_[0] * 2 }, key2 => sub { $_[0] * 4 })
885
+       ->remove_filter
886
+       ->end_filter(key1 => sub { $_[0] * 3 }, key2 => sub { $_[0] * 5 })
885 887
        ->remove_end_filter
886 888
        ->fetch_first;
887
-is_deeply($row, [2, 8]);
889
+is_deeply($row, [1, 2]);
888 890
 
889 891
 test 'empty where select';
890 892
 $dbi = DBIx::Custom->connect($NEW_ARGS->{0});