-#!/usr/bin/perl\r
-\r
-use strict;\r
-use warnings;\r
-use Test::More;\r
-\r
-use SQL::Abstract::Test import => ['is_same_sql_bind'];\r
-\r
-use SQL::Abstract;\r
-\r
-my $sql = SQL::Abstract->new;\r
-\r
-my (@tests, $sub_stmt, @sub_bind, $where);\r
-\r
-#1\r
-($sub_stmt, @sub_bind) = ("SELECT c1 FROM t1 WHERE c2 < ? AND c3 LIKE ?",\r
- 100, "foo%");\r
-$where = {\r
- foo => 1234,\r
- bar => \["IN ($sub_stmt)" => @sub_bind],\r
- };\r
-push @tests, {\r
- where => $where,\r
- stmt => " WHERE ( bar IN (SELECT c1 FROM t1 WHERE c2 < ? AND c3 LIKE ?) AND foo = ? )",\r
- bind => [100, "foo%", 1234],\r
-};\r
-\r
-#2\r
-($sub_stmt, @sub_bind)\r
- = $sql->select("t1", "c1", {c2 => {"<" => 100}, \r
- c3 => {-like => "foo%"}});\r
-$where = {\r
- foo => 1234,\r
- bar => \["> ALL ($sub_stmt)" => @sub_bind],\r
- };\r
-push @tests, {\r
- where => $where,\r
- stmt => " WHERE ( bar > ALL (SELECT c1 FROM t1 WHERE ( c2 < ? AND c3 LIKE ? )) AND foo = ? )",\r
- bind => [100, "foo%", 1234],\r
-};\r
-\r
-#3\r
-($sub_stmt, @sub_bind) \r
- = $sql->select("t1", "*", {c1 => 1, c2 => \"> t0.c0"});\r
-$where = {\r
- foo => 1234,\r
- -nest => \["EXISTS ($sub_stmt)" => @sub_bind],\r
- };\r
-push @tests, {\r
- where => $where,\r
- stmt => " WHERE ( EXISTS (SELECT * FROM t1 WHERE ( c1 = ? AND c2 > t0.c0 )) AND foo = ? )",\r
- bind => [1, 1234],\r
-};\r
-\r
-#4\r
-$where = {\r
- -nest => \["MATCH (col1, col2) AGAINST (?)" => "apples"],\r
- };\r
-push @tests, {\r
- where => $where,\r
- stmt => " WHERE ( MATCH (col1, col2) AGAINST (?) )",\r
- bind => ["apples"],\r
-};\r
-\r
-\r
-#5\r
-($sub_stmt, @sub_bind) \r
- = $sql->where({age => [{"<" => 10}, {">" => 20}]});\r
-$sub_stmt =~ s/^ where //i; # don't want "WHERE" in the subclause\r
-$where = {\r
- lname => {-like => '%son%'},\r
- -nest => \["NOT ( $sub_stmt )" => @sub_bind],\r
- };\r
-push @tests, {\r
- where => $where,\r
- stmt => " WHERE ( NOT ( ( ( ( age < ? ) OR ( age > ? ) ) ) ) AND lname LIKE ? )",\r
- bind => [10, 20, '%son%'],\r
-};\r
-\r
-#6\r
-($sub_stmt, @sub_bind) = ("SELECT c1 FROM t1 WHERE c2 < ? AND c3 LIKE ?",\r
- 100, "foo%");\r
-$where = {\r
- foo => 1234,\r
- bar => { -in => \[$sub_stmt => @sub_bind] },\r
- };\r
-push @tests, {\r
- where => $where,\r
- stmt => " WHERE ( bar IN (SELECT c1 FROM t1 WHERE c2 < ? AND c3 LIKE ?) AND foo = ? )",\r
- bind => [100, "foo%", 1234],\r
-};\r
-\r
-\r
-plan tests => scalar(@tests);\r
-\r
-for (@tests) {\r
-\r
- my($stmt, @bind) = $sql->where($_->{where}, $_->{order});\r
- is_same_sql_bind($stmt, \@bind, $_->{stmt}, $_->{bind});\r
-}\r
-\r
-\r
-\r
-\r
-\r
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Test::More;
+
+use SQL::Abstract::Test import => ['is_same_sql_bind'];
+
+use SQL::Abstract;
+
+my $sql = SQL::Abstract->new;
+
+my (@tests, $sub_stmt, @sub_bind, $where);
+
+#1
+($sub_stmt, @sub_bind) = ("SELECT c1 FROM t1 WHERE c2 < ? AND c3 LIKE ?",
+ 100, "foo%");
+$where = {
+ foo => 1234,
+ bar => \["IN ($sub_stmt)" => @sub_bind],
+ };
+push @tests, {
+ where => $where,
+ stmt => " WHERE ( bar IN (SELECT c1 FROM t1 WHERE c2 < ? AND c3 LIKE ?) AND foo = ? )",
+ bind => [100, "foo%", 1234],
+};
+
+#2
+($sub_stmt, @sub_bind)
+ = $sql->select("t1", "c1", {c2 => {"<" => 100},
+ c3 => {-like => "foo%"}});
+$where = {
+ foo => 1234,
+ bar => \["> ALL ($sub_stmt)" => @sub_bind],
+ };
+push @tests, {
+ where => $where,
+ stmt => " WHERE ( bar > ALL (SELECT c1 FROM t1 WHERE ( c2 < ? AND c3 LIKE ? )) AND foo = ? )",
+ bind => [100, "foo%", 1234],
+};
+
+#3
+($sub_stmt, @sub_bind)
+ = $sql->select("t1", "*", {c1 => 1, c2 => \"> t0.c0"});
+$where = {
+ foo => 1234,
+ -nest => \["EXISTS ($sub_stmt)" => @sub_bind],
+ };
+push @tests, {
+ where => $where,
+ stmt => " WHERE ( EXISTS (SELECT * FROM t1 WHERE ( c1 = ? AND c2 > t0.c0 )) AND foo = ? )",
+ bind => [1, 1234],
+};
+
+#4
+$where = {
+ -nest => \["MATCH (col1, col2) AGAINST (?)" => "apples"],
+ };
+push @tests, {
+ where => $where,
+ stmt => " WHERE ( MATCH (col1, col2) AGAINST (?) )",
+ bind => ["apples"],
+};
+
+
+#5
+($sub_stmt, @sub_bind)
+ = $sql->where({age => [{"<" => 10}, {">" => 20}]});
+$sub_stmt =~ s/^ where //i; # don't want "WHERE" in the subclause
+$where = {
+ lname => {-like => '%son%'},
+ -nest => \["NOT ( $sub_stmt )" => @sub_bind],
+ };
+push @tests, {
+ where => $where,
+ stmt => " WHERE ( NOT ( ( ( ( age < ? ) OR ( age > ? ) ) ) ) AND lname LIKE ? )",
+ bind => [10, 20, '%son%'],
+};
+
+#6
+($sub_stmt, @sub_bind) = ("SELECT c1 FROM t1 WHERE c2 < ? AND c3 LIKE ?",
+ 100, "foo%");
+$where = {
+ foo => 1234,
+ bar => { -in => \[$sub_stmt => @sub_bind] },
+ };
+push @tests, {
+ where => $where,
+ stmt => " WHERE ( bar IN (SELECT c1 FROM t1 WHERE c2 < ? AND c3 LIKE ?) AND foo = ? )",
+ bind => [100, "foo%", 1234],
+};
+
+
+plan tests => scalar(@tests);
+
+for (@tests) {
+
+ my($stmt, @bind) = $sql->where($_->{where}, $_->{order});
+ is_same_sql_bind($stmt, \@bind, $_->{stmt}, $_->{bind});
+}
+
+
+
+
+
-#!/usr/bin/perl\r
-\r
-use strict;\r
-use warnings;\r
-use Test::More;\r
-\r
-use SQL::Abstract::Test import => ['is_same_sql_bind'];\r
-\r
-use SQL::Abstract;\r
-\r
-my $sqlmaker = SQL::Abstract->new(special_ops => [\r
-\r
- # special op for MySql MATCH (field) AGAINST(word1, word2, ...)\r
- {regex => qr/^match$/i, \r
- handler => sub {\r
- my ($self, $field, $op, $arg) = @_;\r
- $arg = [$arg] if not ref $arg;\r
- my $label = $self->_quote($field);\r
- my ($placeholder) = $self->_convert('?');\r
- my $placeholders = join ", ", (($placeholder) x @$arg);\r
- my $sql = $self->_sqlcase('match') . " ($label) "\r
- . $self->_sqlcase('against') . " ($placeholders) ";\r
- my @bind = $self->_bindtype($field, @$arg);\r
- return ($sql, @bind);\r
- }\r
- },\r
-\r
- # special op for Basis+ NATIVE\r
- {regex => qr/^native$/i, \r
- handler => sub {\r
- my ($self, $field, $op, $arg) = @_;\r
- $arg =~ s/'/''/g;\r
- my $sql = "NATIVE (' $field $arg ')";\r
- return ($sql);\r
- }\r
- },\r
-\r
-]);\r
-\r
-my @tests = (\r
-\r
- #1 \r
- { where => {foo => {-match => 'foo'},\r
- bar => {-match => [qw/foo bar/]}},\r
- stmt => " WHERE ( MATCH (bar) AGAINST (?, ?) AND MATCH (foo) AGAINST (?) )",\r
- bind => [qw/foo bar foo/],\r
- },\r
-\r
- #2\r
- { where => {foo => {-native => "PH IS 'bar'"}},\r
- stmt => " WHERE ( NATIVE (' foo PH IS ''bar'' ') )",\r
- bind => [],\r
- },\r
-\r
-);\r
-\r
-\r
-plan tests => scalar(@tests);\r
-\r
-for (@tests) {\r
-\r
- my($stmt, @bind) = $sqlmaker->where($_->{where}, $_->{order});\r
- is_same_sql_bind($stmt, \@bind, $_->{stmt}, $_->{bind});\r
-}\r
-\r
-\r
-\r
-\r
-\r
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Test::More;
+
+use SQL::Abstract::Test import => ['is_same_sql_bind'];
+
+use SQL::Abstract;
+
+my $sqlmaker = SQL::Abstract->new(special_ops => [
+
+ # special op for MySql MATCH (field) AGAINST(word1, word2, ...)
+ {regex => qr/^match$/i,
+ handler => sub {
+ my ($self, $field, $op, $arg) = @_;
+ $arg = [$arg] if not ref $arg;
+ my $label = $self->_quote($field);
+ my ($placeholder) = $self->_convert('?');
+ my $placeholders = join ", ", (($placeholder) x @$arg);
+ my $sql = $self->_sqlcase('match') . " ($label) "
+ . $self->_sqlcase('against') . " ($placeholders) ";
+ my @bind = $self->_bindtype($field, @$arg);
+ return ($sql, @bind);
+ }
+ },
+
+ # special op for Basis+ NATIVE
+ {regex => qr/^native$/i,
+ handler => sub {
+ my ($self, $field, $op, $arg) = @_;
+ $arg =~ s/'/''/g;
+ my $sql = "NATIVE (' $field $arg ')";
+ return ($sql);
+ }
+ },
+
+]);
+
+my @tests = (
+
+ #1
+ { where => {foo => {-match => 'foo'},
+ bar => {-match => [qw/foo bar/]}},
+ stmt => " WHERE ( MATCH (bar) AGAINST (?, ?) AND MATCH (foo) AGAINST (?) )",
+ bind => [qw/foo bar foo/],
+ },
+
+ #2
+ { where => {foo => {-native => "PH IS 'bar'"}},
+ stmt => " WHERE ( NATIVE (' foo PH IS ''bar'' ') )",
+ bind => [],
+ },
+
+);
+
+
+plan tests => scalar(@tests);
+
+for (@tests) {
+
+ my($stmt, @bind) = $sqlmaker->where($_->{where}, $_->{order});
+ is_same_sql_bind($stmt, \@bind, $_->{stmt}, $_->{bind});
+}
+
+
+
+
+
-#!/usr/bin/perl\r
-\r
-use strict;\r
-use warnings;\r
-use Test::More;\r
-use SQL::Abstract;\r
-\r
-plan tests => 13;\r
-\r
-my $obj = bless {}, "Foo::Bar";\r
-\r
-is(SQL::Abstract->_refkind(undef), 'UNDEF', 'UNDEF');\r
-\r
-is(SQL::Abstract->_refkind({}), 'HASHREF', 'HASHREF');\r
-is(SQL::Abstract->_refkind([]), 'ARRAYREF', 'ARRAYREF');\r
-\r
-is(SQL::Abstract->_refkind(\{}), 'HASHREFREF', 'HASHREFREF');\r
-is(SQL::Abstract->_refkind(\[]), 'ARRAYREFREF', 'ARRAYREFREF');\r
-\r
-is(SQL::Abstract->_refkind(\\{}), 'HASHREFREFREF', 'HASHREFREFREF');\r
-is(SQL::Abstract->_refkind(\\[]), 'ARRAYREFREFREF', 'ARRAYREFREFREF');\r
-\r
-is(SQL::Abstract->_refkind("foo"), 'SCALAR', 'SCALAR');\r
-is(SQL::Abstract->_refkind(\"foo"), 'SCALARREF', 'SCALARREF');\r
-is(SQL::Abstract->_refkind(\\"foo"), 'SCALARREFREF', 'SCALARREFREF');\r
-\r
-# objects are treated like scalars\r
-is(SQL::Abstract->_refkind($obj), 'SCALAR', 'SCALAR');\r
-is(SQL::Abstract->_refkind(\$obj), 'SCALARREF', 'SCALARREF');\r
-is(SQL::Abstract->_refkind(\\$obj), 'SCALARREFREF', 'SCALARREFREF');\r
-\r
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Test::More;
+use SQL::Abstract;
+
+plan tests => 13;
+
+my $obj = bless {}, "Foo::Bar";
+
+is(SQL::Abstract->_refkind(undef), 'UNDEF', 'UNDEF');
+
+is(SQL::Abstract->_refkind({}), 'HASHREF', 'HASHREF');
+is(SQL::Abstract->_refkind([]), 'ARRAYREF', 'ARRAYREF');
+
+is(SQL::Abstract->_refkind(\{}), 'HASHREFREF', 'HASHREFREF');
+is(SQL::Abstract->_refkind(\[]), 'ARRAYREFREF', 'ARRAYREFREF');
+
+is(SQL::Abstract->_refkind(\\{}), 'HASHREFREFREF', 'HASHREFREFREF');
+is(SQL::Abstract->_refkind(\\[]), 'ARRAYREFREFREF', 'ARRAYREFREFREF');
+
+is(SQL::Abstract->_refkind("foo"), 'SCALAR', 'SCALAR');
+is(SQL::Abstract->_refkind(\"foo"), 'SCALARREF', 'SCALARREF');
+is(SQL::Abstract->_refkind(\\"foo"), 'SCALARREFREF', 'SCALARREFREF');
+
+# objects are treated like scalars
+is(SQL::Abstract->_refkind($obj), 'SCALAR', 'SCALAR');
+is(SQL::Abstract->_refkind(\$obj), 'SCALARREF', 'SCALARREF');
+is(SQL::Abstract->_refkind(\\$obj), 'SCALARREFREF', 'SCALARREFREF');
+