From: Matt S Trout Date: Mon, 7 Oct 2019 01:14:38 +0000 (+0000) Subject: make sure extraclauses doesn't kill already extant overrides for from X-Git-Tag: v1.90_01~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=116bc0b69bc3d55647a4e195cf212a6af38ba5b8;p=dbsrgits%2FSQL-Abstract.git make sure extraclauses doesn't kill already extant overrides for from --- diff --git a/lib/SQL/Abstract/Plugin/ExtraClauses.pm b/lib/SQL/Abstract/Plugin/ExtraClauses.pm index 10d5839..79912bf 100644 --- a/lib/SQL/Abstract/Plugin/ExtraClauses.pm +++ b/lib/SQL/Abstract/Plugin/ExtraClauses.pm @@ -45,7 +45,6 @@ sub register_extensions { renderer => [ as => '_render_as' ], expander => [ cast => '_expand_cast' ], clause_expanders => [ - "select.from", '_expand_from_list', 'select.group_by' => sub { $_[0]->expand_expr({ -list => $_[2] }, -ident) }, 'select.having' @@ -63,6 +62,24 @@ sub register_extensions { ], ); + $sqla->expander(old_from => $sqla->clause_expander('select.from')); + $sqla->wrap_clause_expander('select.from', sub { + my ($orig) = @_; + sub { + my ($sqla, undef, $args) = @_; + if (ref($args) eq 'HASH') { + return $self->_expand_from_list(undef, $args); + } + if ( + ref($args) eq 'ARRAY' + and grep { !ref($_) and $_ =~ /^-/ } @$args + ) { + return $self->_expand_from_list(undef, $args); + } + return $sqla->$orig(undef, $args); + } + }); + # set ops $sqla->wrap_expander(select => sub { $self->cb('_expand_select', $_[0], \@before_setop);