7 use SQL::Abstract::Test import => ['is_same_sql_bind'];
\r
11 my $sqlmaker = SQL::Abstract->new(special_ops => [
\r
13 # special op for MySql MATCH (field) AGAINST(word1, word2, ...)
\r
14 {regex => qr/^match$/i,
\r
16 my ($self, $field, $op, $arg) = @_;
\r
17 $arg = [$arg] if not ref $arg;
\r
18 my $label = $self->_quote($field);
\r
19 my ($placeholder) = $self->_convert('?');
\r
20 my $placeholders = join ", ", (($placeholder) x @$arg);
\r
21 my $sql = $self->_sqlcase('match') . " ($label) "
\r
22 . $self->_sqlcase('against') . " ($placeholders) ";
\r
23 my @bind = $self->_bindtype($field, @$arg);
\r
24 return ($sql, @bind);
\r
28 # special op for Basis+ NATIVE
\r
29 {regex => qr/^native$/i,
\r
31 my ($self, $field, $op, $arg) = @_;
\r
33 my $sql = "NATIVE (' $field $arg ')";
\r
43 { where => {foo => {-match => 'foo'},
\r
44 bar => {-match => [qw/foo bar/]}},
\r
45 stmt => " WHERE ( MATCH (bar) AGAINST (?, ?) AND MATCH (foo) AGAINST (?) )",
\r
46 bind => [qw/foo bar foo/],
\r
50 { where => {foo => {-native => "PH IS 'bar'"}},
\r
51 stmt => " WHERE ( NATIVE (' foo PH IS ''bar'' ') )",
\r
58 plan tests => scalar(@tests);
\r
62 my($stmt, @bind) = $sqlmaker->where($_->{where}, $_->{order});
\r
63 is_same_sql_bind($stmt, \@bind, $_->{stmt}, $_->{bind});
\r