|
3 | 3 | use strict; |
4 | 4 |
|
5 | 5 | use Data::ObjectDriver::SQL; |
6 | | -use Test::More tests => 103; |
| 6 | +use Test::More tests => 113; |
7 | 7 |
|
8 | 8 | my $stmt = ns(); |
9 | 9 | ok($stmt, 'Created SQL object'); |
@@ -223,6 +223,31 @@ $stmt->add_where(foo => []); |
223 | 223 | is($stmt->as_sql_where, "WHERE (0 = 1)\n"); # foo IN () |
224 | 224 | is(scalar @{ $stmt->bind }, 0); |
225 | 225 |
|
| 226 | +$stmt = ns(); |
| 227 | +$stmt->add_complex_where([]); |
| 228 | +is($stmt->as_sql_where, ""); # no WHERE without expression |
| 229 | +is(scalar @{ $stmt->bind }, 0); |
| 230 | + |
| 231 | +$stmt = ns(); |
| 232 | +$stmt->add_complex_where([[]]); |
| 233 | +is($stmt->as_sql_where, ""); # no WHERE without expression |
| 234 | +is(scalar @{ $stmt->bind }, 0); |
| 235 | + |
| 236 | +$stmt = ns(); |
| 237 | +$stmt->add_complex_where([{}]); |
| 238 | +is($stmt->as_sql_where, ""); # no WHERE without expression |
| 239 | +is(scalar @{ $stmt->bind }, 0); |
| 240 | + |
| 241 | +$stmt = ns(); |
| 242 | +$stmt->add_complex_where([{id => 1}, {}]); |
| 243 | +is($stmt->as_sql_where, "WHERE ((id = ?))\n"); # no empty expression |
| 244 | +is(scalar @{ $stmt->bind }, 1); |
| 245 | + |
| 246 | +$stmt = ns(); |
| 247 | +$stmt->add_complex_where([{id => 1}, []]); |
| 248 | +is($stmt->as_sql_where, "WHERE ((id = ?))\n"); # no empty expression |
| 249 | +is(scalar @{ $stmt->bind }, 1); |
| 250 | + |
226 | 251 | ## regression bug. modified parameters |
227 | 252 | my %terms = ( foo => [-and => 'foo', 'bar', 'baz']); |
228 | 253 | $stmt = ns(); |
|
0 commit comments