{regex => qr/^ (?: not \s )? between $/ix, handler => sub { die "NOPE" }},
{regex => qr/^ is (?: \s+ not )? $/ix, handler => sub { die "NOPE" }},
{regex => qr/^ (?: not \s )? in $/ix, handler => sub { die "NOPE" }},
+ {regex => qr/^ ident $/ix, handler => sub { die "NOPE" }},
+ {regex => qr/^ value $/ix, handler => sub { die "NOPE" }},
);
#======================================================================
push @{$opt{special_ops}}, @BUILTIN_SPECIAL_OPS;
if ($class->isa('DBIx::Class::SQLMaker')) {
- push @{$opt{special_ops}}, our $DBIC_Compat_Op ||= {
- regex => qr/^(?:ident|value|(?:not\s)?in)$/i, handler => sub { die "NOPE" }
- };
$opt{is_dbic_sqlmaker} = 1;
+ $opt{disable_old_special_ops} = 1;
}
# unary operators
-bind => sub { shift; +{ @_ } },
-in => '_expand_in',
-not_in => '_expand_in',
- -list => sub {
+ -tuple => sub {
my ($self, $node, $args) = @_;
+{ $node => [ map $self->expand_expr($_), @$args ] };
},
+ -between => '_expand_between',
+ -not_between => '_expand_between',
};
$opt{expand_op} = {
}
$opt{render} = {
- (map +("-$_", "_render_$_"), qw(op func bind ident literal list)),
+ (map +("-$_", "_render_$_"), qw(op func bind ident literal tuple)),
%{$opt{render}||{}}
};
),
(not => '_render_op_not'),
(map +($_ => '_render_op_andor'), qw(and or)),
- ',' => sub { shift->_render_op_multop(@_, 1) },
+ ',' => '_render_op_multop',
};
return bless \%opt, $class;
if (
(our $Expand_Depth) == 1
+ and $self->{disable_old_special_ops}
and List::Util::first { $op =~ $_->{regex} } @{$self->{special_ops}}
) {
puke "Illegal use of top-level '-$op'"
sub _expand_between {
my ($self, $op, $vv, $k) = @_;
+ $op =~ s/^-//;
+ $k = shift @{$vv = [ @$vv ]} unless defined $k;
local our $Cur_Col_Meta = $k;
my @rhs = map $self->_expand_expr($_),
ref($vv) eq 'ARRAY' ? @$vv : $vv;
sub _expand_in {
my ($self, $raw, $vv, $k) = @_;
$k = shift @{$vv = [ @$vv ]} unless defined $k;
- local our $Cur_Col_Meta = $k;
my $op = $self->_normalize_op($raw);
if (my $literal = is_literal_value($vv)) {
my ($sql, @bind) = @$literal;
return $self->_convert($self->_quote($ident));
}
-sub _render_list {
- my ($self, $list) = @_;
- my ($sql, @bind) = $self->_render_op([ ',', @$list ]);
+sub _render_tuple {
+ my ($self, $values) = @_;
+ my ($sql, @bind) = $self->_render_op([ ',', @$values ]);
return "($sql)", @bind;
}
}
sub _render_op_multop {
- my ($self, $op, $args, $strip_left) = @_;
+ my ($self, $op, $args) = @_;
my @parts = grep length($_->[0]), map [ $self->render_aqt($_) ], @$args;
return '' unless @parts;
return @{$parts[0]} if @parts == 1;
my ($final_sql) = join(
- ($strip_left ? '' : ' ').$self->_sqlcase(join ' ', split '_', $op).' ',
+ ($op eq ',' ? '' : ' ').$self->_sqlcase(join ' ', split '_', $op).' ',
map $_->[0], @parts
);
return (