8 use lib "$FindBin::Bin";
\r
15 my $sql = SQL::Abstract->new;
\r
17 my (@tests, $sub_stmt, @sub_bind, $where);
\r
20 ($sub_stmt, @sub_bind) = ("SELECT c1 FROM t1 WHERE c2 < ? AND c3 LIKE ?",
\r
24 bar => \["IN ($sub_stmt)" => @sub_bind],
\r
28 stmt => " WHERE ( bar IN (SELECT c1 FROM t1 WHERE c2 < ? AND c3 LIKE ?) AND foo = ? )",
\r
29 bind => [100, "foo%", 1234],
\r
33 ($sub_stmt, @sub_bind)
\r
34 = $sql->select("t1", "c1", {c2 => {"<" => 100},
\r
35 c3 => {-like => "foo%"}});
\r
38 bar => \["> ALL ($sub_stmt)" => @sub_bind],
\r
42 stmt => " WHERE ( bar > ALL (SELECT c1 FROM t1 WHERE ( c2 < ? AND c3 LIKE ? )) AND foo = ? )",
\r
43 bind => [100, "foo%", 1234],
\r
47 ($sub_stmt, @sub_bind)
\r
48 = $sql->select("t1", "*", {c1 => 1, c2 => \"> t0.c0"});
\r
51 -nest => \["EXISTS ($sub_stmt)" => @sub_bind],
\r
55 stmt => " WHERE ( EXISTS (SELECT * FROM t1 WHERE ( c1 = ? AND c2 > t0.c0 )) AND foo = ? )",
\r
61 -nest => \["MATCH (col1, col2) AGAINST (?)" => "apples"],
\r
65 stmt => " WHERE ( MATCH (col1, col2) AGAINST (?) )",
\r
71 ($sub_stmt, @sub_bind)
\r
72 = $sql->where({age => [{"<" => 10}, {">" => 20}]});
\r
73 $sub_stmt =~ s/^ where //i; # don't want "WHERE" in the subclause
\r
75 lname => {-like => '%son%'},
\r
76 -nest => \["NOT ( $sub_stmt )" => @sub_bind],
\r
80 stmt => " WHERE ( NOT ( ( ( ( age < ? ) OR ( age > ? ) ) ) ) AND lname LIKE ? )",
\r
81 bind => [10, 20, '%son%'],
\r
88 my($stmt, @bind) = $sql->where($_->{where}, $_->{order});
\r
89 is_same_sql_bind($stmt, \@bind, $_->{stmt}, $_->{bind});
\r