7 use SQL::Abstract::Test qw/is_same_sql_bind/;
\r
12 my $sql = SQL::Abstract->new;
\r
14 my (@tests, $sub_stmt, @sub_bind, $where);
\r
17 ($sub_stmt, @sub_bind) = ("SELECT c1 FROM t1 WHERE c2 < ? AND c3 LIKE ?",
\r
21 bar => \["IN ($sub_stmt)" => @sub_bind],
\r
25 stmt => " WHERE ( bar IN (SELECT c1 FROM t1 WHERE c2 < ? AND c3 LIKE ?) AND foo = ? )",
\r
26 bind => [100, "foo%", 1234],
\r
30 ($sub_stmt, @sub_bind)
\r
31 = $sql->select("t1", "c1", {c2 => {"<" => 100},
\r
32 c3 => {-like => "foo%"}});
\r
35 bar => \["> ALL ($sub_stmt)" => @sub_bind],
\r
39 stmt => " WHERE ( bar > ALL (SELECT c1 FROM t1 WHERE ( c2 < ? AND c3 LIKE ? )) AND foo = ? )",
\r
40 bind => [100, "foo%", 1234],
\r
44 ($sub_stmt, @sub_bind)
\r
45 = $sql->select("t1", "*", {c1 => 1, c2 => \"> t0.c0"});
\r
48 -nest => \["EXISTS ($sub_stmt)" => @sub_bind],
\r
52 stmt => " WHERE ( EXISTS (SELECT * FROM t1 WHERE ( c1 = ? AND c2 > t0.c0 )) AND foo = ? )",
\r
58 -nest => \["MATCH (col1, col2) AGAINST (?)" => "apples"],
\r
62 stmt => " WHERE ( MATCH (col1, col2) AGAINST (?) )",
\r
68 ($sub_stmt, @sub_bind)
\r
69 = $sql->where({age => [{"<" => 10}, {">" => 20}]});
\r
70 $sub_stmt =~ s/^ where //i; # don't want "WHERE" in the subclause
\r
72 lname => {-like => '%son%'},
\r
73 -nest => \["NOT ( $sub_stmt )" => @sub_bind],
\r
77 stmt => " WHERE ( NOT ( ( ( ( age < ? ) OR ( age > ? ) ) ) ) AND lname LIKE ? )",
\r
78 bind => [10, 20, '%son%'],
\r
85 my($stmt, @bind) = $sql->where($_->{where}, $_->{order});
\r
86 is_same_sql_bind($stmt, \@bind, $_->{stmt}, $_->{bind});
\r