$logic ||= 'and';
local $self->{_nested_func_lhs} = $self->{_nested_func_lhs};
- $self->{_nested_func_lhs} ||= $k;
my ($all_sql, @all_bind);
},
FALLBACK => sub { # CASE: col => {op/func => $stuff}
+
+ # if we are starting to nest and the first func is not a cmp op
+ # assume equality
+ my $prefix;
+ unless ($self->{_nested_func_lhs}) {
+ $self->{_nested_func_lhs} = $k;
+ $prefix = $self->{cmp} unless $op =~ $self->{cmp_ops};
+ }
+
($sql, @bind) = $self->_where_func_generic ($op, $val);
- $sql = join ' ', $self->_convert($self->_quote($k)), $sql;
+ $sql = join ' ', $self->_convert($self->_quote($k)), $prefix||(), $sql;
},
});
}
#26
{
func => 'select',
- args => ['test', '*', {priority => [ -and => {'!=', 2}, {'!=', 1} ]}],
- stmt => 'SELECT * FROM test WHERE ( ( ( priority != ? ) AND ( priority != ? ) ) )',
- stmt_q => 'SELECT * FROM `test` WHERE ( ( ( `priority` != ? ) AND ( `priority` != ? ) ) )',
- bind => [qw(2 1)],
+ args => ['test', '*', {priority => [ -and => {'!=', 2}, { -not_like => '3%'} ]}],
+ stmt => 'SELECT * FROM test WHERE ( ( ( priority != ? ) AND ( priority NOT LIKE ? ) ) )',
+ stmt_q => 'SELECT * FROM `test` WHERE ( ( ( `priority` != ? ) AND ( `priority` NOT LIKE ? ) ) )',
+ bind => [qw(2 3%)],
},
#27
{
stmt_q => 'INSERT INTO `test` VALUES (?, ?, ?, ?, ?) RETURNING id',
bind => [qw/1 2 3 4 5/],
},
+ {
+ func => 'select',
+ new => {bindtype => 'columns'},
+ args => ['test', '*', [ Y => { -max => { -LENGTH => { -min => 'x' } } } ] ],
+ stmt => 'SELECT * FROM test WHERE ( Y = MAX( LENGTH( MIN( ? ) ) ) )',
+ stmt_q => 'SELECT * FROM `test` WHERE ( `Y` = MAX( LENGTH( MIN( ? ) ) ) )',
+ bind => [[Y => 'x']],
+ },
);