-#!/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
-plan tests => 2;\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
-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 => [],
+ },
+
+);
+
+for (@tests) {
+
+ my($stmt, @bind) = $sqlmaker->where($_->{where}, $_->{order});
+ is_same_sql_bind($stmt, \@bind, $_->{stmt}, $_->{bind});
+}
+
+done_testing;