From: Matt S Trout Date: Mon, 7 Oct 2019 01:17:26 +0000 (+0000) Subject: expand bangoverrides from order_by keys too for compat reasons X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2ed2b14f25282f6674aab891455901f9d128e0de;p=scpubgit%2FQ-Branch.git expand bangoverrides from order_by keys too for compat reasons --- diff --git a/lib/SQL/Abstract/Plugin/BangOverrides.pm b/lib/SQL/Abstract/Plugin/BangOverrides.pm index 3a0b377..dae9d0c 100644 --- a/lib/SQL/Abstract/Plugin/BangOverrides.pm +++ b/lib/SQL/Abstract/Plugin/BangOverrides.pm @@ -7,19 +7,26 @@ with 'SQL::Abstract::Role::Plugin'; sub register_extensions { my ($self, $sqla) = @_; foreach my $stmt ($sqla->statement_list) { - $sqla->wrap_expander($stmt => sub ($orig) { + $sqla->wrap_expander($stmt => sub { + my ($orig) = @_; sub { my ($self, $name, $args) = @_; - my %args = %$args; + my %args = ( + %$args, + (ref($args->{order_by}) eq 'HASH' + ? %{$args->{order_by}} + : ()) + ); + my %overrides; foreach my $clause (map /^!(.*)$/, keys %args) { my $override = delete $args{"!${clause}"}; - $args{$clause} = ( + $overrides{$clause} = ( ref($override) eq 'CODE' - ? $override->($args{$clause}) + ? $self->$override($args{$clause}) : $override ); } - $self->$orig($name, \%args); + $self->$orig($name, { %$args, %overrides }); } }); }