From: Matt S Trout Date: Mon, 15 Apr 2019 02:03:18 +0000 (+0000) Subject: clauses transforms X-Git-Tag: v1.90_01~210 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ee706e89c8703b720f970a16163d36de9a30e7d4;p=dbsrgits%2FSQL-Abstract.git clauses transforms --- diff --git a/lib/SQL/Abstract/Clauses.pm b/lib/SQL/Abstract/Clauses.pm index 877117d..3683f45 100644 --- a/lib/SQL/Abstract/Clauses.pm +++ b/lib/SQL/Abstract/Clauses.pm @@ -302,6 +302,9 @@ sub clauses_of { unless (@clauses) { return @{$self->{clauses_of}{$of}||[]}; } + if (ref($clauses[0]) eq 'CODE') { + @clauses = $self->${\($clauses[0])}(@{$self->{clauses_of}{$of}||[]}); + } $self->{clauses_of}{$of} = \@clauses; return $self; } diff --git a/lib/SQL/Abstract/ExtraClauses.pm b/lib/SQL/Abstract/ExtraClauses.pm index c46a632..00e4d2a 100644 --- a/lib/SQL/Abstract/ExtraClauses.pm +++ b/lib/SQL/Abstract/ExtraClauses.pm @@ -28,8 +28,18 @@ sub register_defaults { $self->expander(as => '_expand_op_as'); $self->renderer(as => '_render_as'); - splice(@{$self->{clauses_of}{update}}, 2, 0, 'from'); - splice(@{$self->{clauses_of}{delete}}, 1, 0, 'using'); + $self->clauses_of(update => sub { + my ($self, @clauses) = @_; + splice(@clauses, 2, 0, 'from'); + @clauses; + }); + + $self->clauses_of(delete => sub { + my ($self, @clauses) = @_; + splice(@clauses, 1, 0, 'using'); + @clauses; + }); + $self->clause_expanders( 'update.from' => '_expand_select_clause_from', 'delete.using' => sub {