Showing 3 changed files with 21 additions and 3 deletions
+1
Changes
... ...
@@ -1,5 +1,6 @@
1 1
 0.1678
2 2
     - DBIx::Custom::Model filter attribute can receive hash reference
3
+    - DBIx::Custom::Where clause attribute can receive clause without column name.
3 4
 0.1677
4 5
     - improved table search in column and join clause
5 6
     - DEPRECATED table tag. use table option.
+11 -3
lib/DBIx/Custom/Where.pm
... ...
@@ -70,11 +70,20 @@ sub _parse {
70 70
     
71 71
     # String
72 72
     else {
73
+        # Pushed
74
+        my $pushed;
73 75
         
74 76
         # Column
75 77
         my $columns = $self->query_builder->build_query($clause)->columns;
76
-        croak qq{Each tag contains one column name: tag "$clause"}
77
-          unless @$columns == 1;
78
+        if (@$columns == 0) {
79
+            push @$where, $clause;
80
+            $pushed = 1;
81
+            return $pushed;
82
+        }
83
+        elsif (@$columns != 1) {
84
+            croak qq{Each tag contains one column name: tag "$clause"}
85
+        }
86
+
78 87
         my $column = $columns->[0];
79 88
         if (my $q = $self->reserved_word_quote) {
80 89
             $column =~ s/$q//g;
... ...
@@ -89,7 +98,6 @@ sub _parse {
89 98
         
90 99
         # Push
91 100
         my $param = $self->param;
92
-        my $pushed;
93 101
         if (ref $param eq 'HASH') {
94 102
             if (exists $param->{$column}) {
95 103
                 if (ref $param->{$column} eq 'ARRAY') {
+9
t/dbix-custom-core-sqlite.t
... ...
@@ -1249,6 +1249,15 @@ $result = $dbi->select(
1249 1249
 $row = $result->fetch_hash_all;
1250 1250
 is_deeply($row, [{key1 => 1, key2 => 2}], 'not_exists');
1251 1251
 
1252
+$where = $dbi->where
1253
+             ->clause(['and', 'key1 is not null', 'key2 is not null' ]);
1254
+$result = $dbi->select(
1255
+    table => 'table1',
1256
+    where => $where,
1257
+);
1258
+$row = $result->fetch_hash_all;
1259
+is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], 'not_exists');
1260
+
1252 1261
 test 'dbi_option default';
1253 1262
 $dbi = DBIx::Custom->new;
1254 1263
 is_deeply($dbi->dbi_option, {});