my $op = $self->_normalize_op($k);
- if (my $exp = $self->{expand}{$op}) {
- return $self->$exp($op, $v);
- }
-
- # Ops prefixed with -not_ get converted
-
- if (my ($rest) = $op =~/^not_(.*)$/) {
- return +{ -op => [
- 'not',
- $self->_expand_expr({ "-${rest}", $v })
- ] };
- }
-
{ # Old SQLA compat
my $op = join(' ', split '_', $op);
) {
puke "Illegal use of top-level '-$op'"
}
+ }
+
+ if (my $exp = $self->{expand}{$op}) {
+ return $self->$exp($op, $v);
+ }
+
+ # Ops prefixed with -not_ get converted
+
+ if (my ($rest) = $op =~/^not_(.*)$/) {
+ return +{ -op => [
+ 'not',
+ $self->_expand_expr({ "-${rest}", $v })
+ ] };
+ }
+
+ { # Old SQLA compat
# the old unary op system means we should touch nothing and let it work
+ my $op = join(' ', split '_', $op);
+
if (my $us = List::Util::first { $op =~ $_->{regex} } @{$self->{unary_ops}}) {
return { -op => [ $op, $v ] };
}
$sql_maker->where({ foo => { -ident => undef } })
} qr/-ident requires a single plain scalar argument/;
+ throws_ok {
+ local $sql_maker->{disable_old_special_ops} = 1;
+ $sql_maker->where({'-or' => [{'-ident' => 'foo'},'foo']})
+ } qr/Illegal.*top-level/;
+
+ throws_ok {
+ local $sql_maker->{disable_old_special_ops} = 1;
+ $sql_maker->where({'-or' => [{'-ident' => 'foo'},{'=' => \'bozz'}]})
+ } qr/Illegal.*top-level/;
+
my ($sql, @bind) = $sql_maker->select('artist', '*', { 'artist.name' => { -ident => 'artist.pseudonym' } } );
is_same_sql_bind (
$sql,