Skip to content

Commit 918ae0d

Browse files
committed
Add tests for empty where expressions
1 parent 2dc6087 commit 918ae0d

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

t/11-sql.t

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use strict;
44

55
use Data::ObjectDriver::SQL;
6-
use Test::More tests => 103;
6+
use Test::More tests => 113;
77

88
my $stmt = ns();
99
ok($stmt, 'Created SQL object');
@@ -223,6 +223,31 @@ $stmt->add_where(foo => []);
223223
is($stmt->as_sql_where, "WHERE (0 = 1)\n"); # foo IN ()
224224
is(scalar @{ $stmt->bind }, 0);
225225

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+
226251
## regression bug. modified parameters
227252
my %terms = ( foo => [-and => 'foo', 'bar', 'baz']);
228253
$stmt = ns();

0 commit comments

Comments
 (0)