From: Matt S Trout Date: Tue, 9 Apr 2019 00:18:28 +0000 (+0000) Subject: expand update expansion X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=889fdd38abdd4582676a6d383fa0ac23fa9ee268;p=scpubgit%2FQ-Branch.git expand update expansion --- diff --git a/lib/SQL/Abstract/Clauses.pm b/lib/SQL/Abstract/Clauses.pm index d769abd..4da4500 100644 --- a/lib/SQL/Abstract/Clauses.pm +++ b/lib/SQL/Abstract/Clauses.pm @@ -21,14 +21,8 @@ sub register_defaults { $self->{clauses_of}{update} = [ qw(update set where returning) ]; $self->{expand}{update} = sub { shift->_expand_statement(@_) }; $self->{render}{update} = sub { shift->_render_statement(update => @_) }; - $self->{expand_clause}{'update.update'} = sub { - $_[0]->expand_expr($_[1], -ident) - }; - $self->{expand_clause}{'update.set'} = '_expand_update_set_values'; - $self->{expand_clause}{'update.where'} = 'expand_expr'; - $self->{expand_clause}{'update.returning'} = sub { - shift->_expand_maybe_list_expr(@_, -ident); - }; + $self->{expand_clause}{"update.$_"} = "_expand_update_clause_$_" + for @{$self->{clauses_of}{update}}; $self->{clauses_of}{delete} = [ qw(delete_from where returning) ]; $self->{expand}{delete} = sub { shift->_expand_statement(@_) }; $self->{render}{delete} = sub { shift->_render_statement(delete => @_) }; @@ -76,6 +70,23 @@ sub _expand_select_clause_order_by { +(order_by => $self->_expand_order_by($order_by)); } +sub _expand_update_clause_update { + my ($self, $target) = @_; + +(update => $self->expand_expr($target, -ident)); +} + +sub _expand_update_clause_set { + +(set => shift->_expand_update_set_values(@_)); +} + +sub _expand_update_clause_where { + +(where => shift->expand_expr(@_)); +} + +sub _expand_update_clause_returning { + +(returning => shift->_expand_maybe_list_expr(@_, -ident)); +} + sub _expand_statement { my ($self, $type, $args) = @_; my $ec = $self->{expand_clause};