Showing 6 changed files with 53 additions and 3 deletions
+1
Changes
... ...
@@ -1,4 +1,5 @@
1 1
 0.1653
2
+    - added experimental DBIx::Custom::Result remove_end_filter()
2 3
     - added experimental DBIx::Custom::Model insert_at()
3 4
     - added experimental insert_at()
4 5
     - improved error message
+19 -3
lib/DBIx/Custom.pm
... ...
@@ -1435,7 +1435,7 @@ Arguments is same as C<delete> method,
1435 1435
 except that C<delete_all> don't have C<where> argument.
1436 1436
 Return value of C<delete_all()> is the count of affected rows.
1437 1437
 
1438
-=head3 C<delete_at()>
1438
+=head3 C<(experimental) delete_at()>
1439 1439
 
1440 1440
 To delete row by using primary key, use C<delete_at()>
1441 1441
 
... ...
@@ -1476,6 +1476,22 @@ default to 0. This is experimental.
1476 1476
 This is overwrites C<default_bind_filter>.
1477 1477
 Return value of C<insert()> is the count of affected rows.
1478 1478
 
1479
+=head3 C<(experimental) insert_at()>
1480
+
1481
+To insert row by using primary key, use C<insert_at()>
1482
+
1483
+    $dbi->insert_at(
1484
+        table => 'book',
1485
+        primary_key => ['id'],
1486
+        where => ['123'],
1487
+        param => {name => 'Ken'}
1488
+    );
1489
+
1490
+In this example, row which id column is 123 is inserted.
1491
+NOTE that you must pass array reference as C<where>.
1492
+If C<param> contains primary key,
1493
+the key and value is delete from C<param>.
1494
+
1479 1495
 =head2 C<(experimental) each_column>
1480 1496
 
1481 1497
     $dbi->each_column(
... ...
@@ -1648,7 +1664,7 @@ First element is a string. it contains tags,
1648 1664
 such as "{= title} or {like author}".
1649 1665
 Second element is paramters.
1650 1666
 
1651
-=head3 C<select_at()>
1667
+=head3 C<(experimental) select_at()>
1652 1668
 
1653 1669
 To select row by using primary key, use C<select_at()>.
1654 1670
 
... ...
@@ -1709,7 +1725,7 @@ Arguments is same as C<update> method,
1709 1725
 except that C<update_all> don't have C<where> argument.
1710 1726
 Return value of C<update_all()> is the count of affected rows.
1711 1727
 
1712
-=head3 C<update_at()>
1728
+=head3 C<(experimental) update_at()>
1713 1729
 
1714 1730
 To update row by using primary key, use C<update_at()>
1715 1731
 
+4
lib/DBIx/Custom/Guide.pod
... ...
@@ -693,6 +693,10 @@ use C<end_filter()> to add end filter.
693 693
 
694 694
 In this example, L<Time::Piece> object is converted to readable format.
695 695
 
696
+You can remove end_filter by C<end_filter>
697
+
698
+    $result->remove_end_filter;
699
+
696 700
 =head3 Automate applying filter : C<each_column()>
697 701
 
698 702
 It is useful to apply filter automatically at date type columns.
+4
lib/DBIx/Custom/Guide/Ja.pod
... ...
@@ -703,6 +703,10 @@ C<DBIx::Custom::Result>のC<filter()>を使用します。
703 703
 
704 704
 この例ではL<Time::Piece>オブジェクトを読みやすい書式に変換しています。
705 705
 
706
+最後のフィルタリングをC<remove_filter()>で取り除くこともできます。
707
+
708
+$result->remove_end_filter;
709
+
706 710
 =head3 フィルタの適用の自動化 C<each_column()>
707 711
 
708 712
 日付型の列は自動的にフィルタを適用できると便利です。
+14
lib/DBIx/Custom/Result.pm
... ...
@@ -247,6 +247,14 @@ sub fetch_multi {
247 247
     return $rows;
248 248
 }
249 249
 
250
+sub remove_end_filter {
251
+    my $self = shift;
252
+    
253
+    $self->{end_filter} = {};
254
+    
255
+    return $self;
256
+}
257
+
250 258
 # Deprecated
251 259
 sub default_filter {
252 260
     my $self = shift;
... ...
@@ -428,6 +436,12 @@ Filters.
428 436
 These each filters override the filters applied by C<apply_filter> of
429 437
 L<DBIx::Custom>.
430 438
 
439
+=head2 C<(experimental) remove_end_filter>
440
+
441
+    $result->remove_end_filter;
442
+
443
+Remove end filter.
444
+
431 445
 =head2 C<(experimental) stash>
432 446
 
433 447
     my $stash = $result->stash;
+11
t/dbix-custom-core-sqlite.t
... ...
@@ -875,6 +875,17 @@ $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';
879
+$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
880
+$dbi->execute($CREATE_TABLE->{0});
881
+$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
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 })
885
+       ->remove_end_filter
886
+       ->fetch_first;
887
+is_deeply($row, [2, 8]);
888
+
878 889
 test 'empty where select';
879 890
 $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
880 891
 $dbi->execute($CREATE_TABLE->{0});