map {
my ($k, $set) = @$_;
$set = { -bind => $_ } unless defined $set;
- +{ -op => [ '=', $self->_expand_ident(-ident => $k), $set ] };
+ +{ -op => [ '=', { -ident => $k }, $set ] };
}
map {
my $k = $_;
sub _expand_hashtriple {
my ($self, $k, $vk, $vv) = @_;
- my $ik = $self->_expand_ident(-ident => $k);
+ my $ik = $self->_expand_expr({ -ident => $k });
my $op = $self->_normalize_op($vk);
$self->_assert_pass_injection_guard($op);
sub _expand_func {
my ($self, undef, $args) = @_;
my ($func, @args) = @$args;
- return { -func => [ $func, map $self->expand_expr($_), @args ] };
+ return +{ -func => [ $func, map $self->expand_expr($_), @args ] };
}
sub _expand_ident {
return $self->_expand_expr($v);
}
puke "-bool => undef not supported" unless defined($v);
- return $self->_expand_ident(-ident => $v);
+ return $self->_expand_expr({ -ident => $v });
}
sub _expand_op_andor {
$self->{expand}{exists} = sub {
$_[0]->_expand_op(undef, [ exists => $_[2] ]);
};
- $self->{render}{convert_where} = sub {
- my $self = shift;
- local $self->{convert_where} = $self->{convert};
- $self->render_aqt($_[1]);
- };
return $self;
}
sub _expand_select_clause_where {
my ($self, undef, $where) = @_;
+
+ local (@{$self->{expand}}{qw(ident value)},
+ @{$self->{expand_op}}{qw(ident value)},
+ $self->{expand_op}{bind})
+ = (map {
+ my $orig = $self->{expand}{$_};
+ sub {
+ my $self = shift;
+ +{ -func => [
+ $self->{convert},
+ $self->$orig(@_)
+ ] };
+ }
+ } qw(ident value ident value bind)
+ ) if $self->{convert};
+
+ local $self->{expand}{func} = do {
+ my $orig = $self->{expand}{func};
+ sub {
+ my ($self, $type, $thing) = @_;
+ if (ref($thing) eq 'ARRAY' and $thing->[0] eq $self->{convert}
+ and @$thing == 2 and ref($thing->[1]) eq 'HASH'
+ and (
+ $thing->[1]{-ident}
+ or $thing->[1]{-value}
+ or $thing->[1]{-bind})
+ ) {
+ return { -func => $thing }; # already went through our expander
+ }
+ return $self->$orig($type, $thing);
+ }
+ } if $self->{convert};
+
my $exp = $self->expand_expr($where);
- +(where => ($self->{convert} ? +{ -convert_where => $exp } : $exp));
+ +(where => $exp);
}
sub _expand_select_clause_order_by {
}
return $data if ref($data) eq 'HASH' and $data->{-row};
my ($f_aqt, $v_aqt) = $self->_expand_insert_values($data);
- return (from => { -values => $v_aqt }, ($f_aqt ? (fields => $f_aqt) : ()));
+ return (
+ from => { -values => [ $v_aqt ] },
+ ($f_aqt ? (fields => $f_aqt) : ()),
+ );
}
sub _expand_insert_clause_returning {
my $e1 = $self->$orig(@args);
my $e2 = $self->$orig($e1);
(our $tb)->is_eq(
- (map Data::Dumper::Concise::Dumper($_), $e1, $e2),
+ (map Data::Dumper::Concise::Dumper($_), $e2, $e1),
'expand_expr stability ok'
- );
+ );# or die;
return $e1;
};
no strict 'refs'; no warnings 'redefine';