5 use SQL::Abstract::Test import => ['is_same_sql_bind'];
9 my $sqlmaker = SQL::Abstract->new(special_ops => [
11 # special op for MySql MATCH (field) AGAINST(word1, word2, ...)
12 {regex => qr/^match$/i,
14 my ($self, $field, $op, $arg) = @_;
15 $arg = [$arg] if not ref $arg;
16 my $label = $self->_quote($field);
17 my ($placeholder) = $self->_convert('?');
18 my $placeholders = join ", ", (($placeholder) x @$arg);
19 my $sql = $self->_sqlcase('match') . " ($label) "
20 . $self->_sqlcase('against') . " ($placeholders) ";
21 my @bind = $self->_bindtype($field, @$arg);
26 # special op for Basis+ NATIVE
27 {regex => qr/^native$/i,
29 my ($self, $field, $op, $arg) = @_;
31 my $sql = "NATIVE (' $field $arg ')";
41 { where => {foo => {-match => 'foo'},
42 bar => {-match => [qw/foo bar/]}},
43 stmt => " WHERE ( MATCH (bar) AGAINST (?, ?) AND MATCH (foo) AGAINST (?) )",
44 bind => [qw/foo bar foo/],
48 { where => {foo => {-native => "PH IS 'bar'"}},
49 stmt => " WHERE ( NATIVE (' foo PH IS ''bar'' ') )",
57 my($stmt, @bind) = $sqlmaker->where($_->{where}, $_->{order});
58 is_same_sql_bind($stmt, \@bind, $_->{stmt}, $_->{bind});