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