Showing 4 changed files with 38 additions and 14 deletions
+1
Changes
... ...
@@ -1,4 +1,5 @@
1 1
 0.1644
2
+  became more useful where method
2 3
   changed DBIx::Custom::Where greatly
3 4
 0.1633
4 5
   fixed test
-4
lib/DBIx/Custom.pm
... ...
@@ -1412,10 +1412,6 @@ B<Example:>
1412 1412
 
1413 1413
 Create a new L<DBIx::Custom::Where> object.
1414 1414
 
1415
-=head2 C<experimental) build_where>
1416
-
1417
-
1418
-
1419 1415
 =head2 C<(deprecated) default_bind_filter>
1420 1416
 
1421 1417
     my $default_bind_filter = $dbi->default_bind_filter;
+7 -3
lib/DBIx/Custom/Where.pm
... ...
@@ -113,11 +113,15 @@ DBIx::Custom::Where - Where clause
113 113
 
114 114
 =head2 C<clause>
115 115
 
116
-    $where->clause(title => '{= title}', date => ['{< date}', '{> date}']);
116
+    $where->clause(
117
+        ['and', '{= title}', ['or', '{< date}', '{> date}']]
118
+    );
117 119
 
118
-Where clause. These clauses is joined by ' and ' at C<to_string()>
119
-if corresponding parameter name is exists in C<param>.
120
+Where clause.
120 121
 
121 122
 =head2 C<to_string>
122 123
 
123 124
     $where->to_string;
125
+
126
+Convert where clause to string correspoinding to param name.
127
+
+30 -7
t/dbix-custom-core-sqlite.t
... ...
@@ -868,13 +868,9 @@ $result = $dbi->select(
868 868
 $row = $result->fetch_hash_all;
869 869
 is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]);
870 870
 
871
-__END__
872
-
873 871
 eval {
874 872
 $where = $dbi->where
875
-             ->clause(key1 => "{= key1}" )
876
-             ->or_clause(key2 => "{= key2}" )
877
-             ->param({key3 => 5});
873
+             ->clause(['uuu']);
878 874
 $result = $dbi->select(
879 875
     table => 'table1',
880 876
     where => $where
... ...
@@ -885,8 +881,35 @@ ok($@);
885 881
 $where = $dbi->where;
886 882
 is("$where", '');
887 883
 
888
-$where = $dbi->where->clause(key1 => 'pppp')->param({key1 => 1});
889
-like("$where", qr/pppp/);
884
+$where = $dbi->where
885
+             ->clause(['or', ('{= key1}') x 2])
886
+             ->param({key1 => [1, 3]});
887
+$result = $dbi->select(
888
+    table => 'table1',
889
+    where => $where,
890
+);
891
+$row = $result->fetch_hash_all;
892
+is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]);
893
+
894
+$where = $dbi->where
895
+             ->clause(['or', ('{= key1}') x 2])
896
+             ->param({key1 => [1]});
897
+$result = $dbi->select(
898
+    table => 'table1',
899
+    where => $where,
900
+);
901
+$row = $result->fetch_hash_all;
902
+is_deeply($row, [{key1 => 1, key2 => 2}]);
903
+
904
+$where = $dbi->where
905
+             ->clause(['or', ('{= key1}') x 2])
906
+             ->param({key1 => 1});
907
+$result = $dbi->select(
908
+    table => 'table1',
909
+    where => $where,
910
+);
911
+$row = $result->fetch_hash_all;
912
+is_deeply($row, [{key1 => 1, key2 => 2}]);
890 913
 
891 914
 test 'dbi_options default';
892 915
 $dbi = DBIx::Custom->new;