... | ... |
@@ -1,3 +1,5 @@ |
1 |
+0.1698 |
|
2 |
+ - fixed DBIx::Custom::Where to_string method small bug |
|
1 | 3 |
0.1697 |
2 | 4 |
- added EXPERIMENTAL map_param method |
3 | 5 |
0.1696 |
... | ... |
@@ -67,20 +67,24 @@ sub _parse { |
67 | 67 |
qq{"$op" is passed} . _subname . ")" |
68 | 68 |
unless $VALID_OPERATIONS{$op}; |
69 | 69 |
|
70 |
+ my $pushed_array; |
|
70 | 71 |
# Parse internal clause |
71 | 72 |
for (my $i = 1; $i < @$clause; $i++) { |
72 | 73 |
my $pushed = $self->_parse($clause->[$i], $where, $count, $op); |
73 | 74 |
push @$where, $op if $pushed; |
75 |
+ $pushed_array = 1 if $pushed; |
|
74 | 76 |
} |
75 | 77 |
pop @$where if $where->[-1] eq $op; |
76 | 78 |
|
77 | 79 |
# Undo |
78 | 80 |
if ($where->[-1] eq '(') { |
79 | 81 |
pop @$where; |
80 |
- pop @$where; |
|
82 |
+ pop @$where if ($where->[-1] || '') eq $op; |
|
81 | 83 |
} |
82 | 84 |
# End |
83 | 85 |
else { push @$where, ')' } |
86 |
+ |
|
87 |
+ return $pushed_array; |
|
84 | 88 |
} |
85 | 89 |
|
86 | 90 |
# String |
... | ... |
@@ -139,6 +143,7 @@ sub _parse { |
139 | 143 |
} |
140 | 144 |
return $pushed; |
141 | 145 |
} |
146 |
+ return; |
|
142 | 147 |
} |
143 | 148 |
|
144 | 149 |
1; |
... | ... |
@@ -1342,6 +1342,30 @@ is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], 'not_exists'); |
1342 | 1342 |
eval {$dbi->where(ppp => 1) }; |
1343 | 1343 |
like($@, qr/invalid/); |
1344 | 1344 |
|
1345 |
+$where = $dbi->where( |
|
1346 |
+ clause => ['and', ['or'], ['and', 'key1 = :key1', 'key2 = :key2']], |
|
1347 |
+ param => {key1 => 1, key2 => 2} |
|
1348 |
+); |
|
1349 |
+$result = $dbi->select( |
|
1350 |
+ table => 'table1', |
|
1351 |
+ where => $where, |
|
1352 |
+); |
|
1353 |
+$row = $result->all; |
|
1354 |
+is_deeply($row, [{key1 => 1, key2 => 2}]); |
|
1355 |
+ |
|
1356 |
+ |
|
1357 |
+$where = $dbi->where( |
|
1358 |
+ clause => ['and', ['or'], ['or', ':key1', ':key2']], |
|
1359 |
+ param => {} |
|
1360 |
+); |
|
1361 |
+$result = $dbi->select( |
|
1362 |
+ table => 'table1', |
|
1363 |
+ where => $where, |
|
1364 |
+); |
|
1365 |
+$row = $result->all; |
|
1366 |
+is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]); |
|
1367 |
+ |
|
1368 |
+ |
|
1345 | 1369 |
test 'dbi_option default'; |
1346 | 1370 |
$dbi = DBIx::Custom->new; |
1347 | 1371 |
is_deeply($dbi->dbi_option, {}); |