From: Matt S Trout Date: Sun, 21 Apr 2019 02:42:50 +0000 (+0000) Subject: rebuild convert using extension system X-Git-Tag: v1.90_01~159 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=91c490fabb738b3fae25349c2271f3dd362c14b0;p=dbsrgits%2FSQL-Abstract.git rebuild convert using extension system --- diff --git a/lib/SQL/Abstract/Clauses.pm b/lib/SQL/Abstract/Clauses.pm index 68dad06..78ec300 100644 --- a/lib/SQL/Abstract/Clauses.pm +++ b/lib/SQL/Abstract/Clauses.pm @@ -79,40 +79,43 @@ sub _expand_select_clause_from { 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); + my $sqla = do { + if (my $conv = $self->{convert}) { + my $_wrap = sub { + my $orig = shift; + sub { + my $self = shift; + +{ -func => [ + $conv, + $self->$orig(@_) + ] }; + }; + }; + $self->clone + ->wrap_expanders(map +($_ => $_wrap), qw(ident value bind)) + ->wrap_op_expanders(map +($_ => $_wrap), qw(ident value bind)) + ->wrap_expander(func => sub { + my $orig = shift; + sub { + my ($self, $type, $thing) = @_; + if (ref($thing) eq 'ARRAY' and $thing->[0] eq $conv + 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); + } + }); + } else { + $self; } - } if $self->{convert}; + }; - my $exp = $self->expand_expr($where); - +(where => $exp); + return +(where => $sqla->expand_expr($where)); } sub _expand_select_clause_order_by {