From: Matt S Trout Date: Tue, 9 Apr 2019 00:36:25 +0000 (+0000) Subject: convert delete to extended clauses system X-Git-Tag: v2.000000~3^2~262 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bc637c4f59db4bfd6f9635088d297f99d99abc4f;p=dbsrgits%2FSQL-Abstract.git convert delete to extended clauses system --- diff --git a/lib/SQL/Abstract/Clauses.pm b/lib/SQL/Abstract/Clauses.pm index 4da4500..0ae82ac 100644 --- a/lib/SQL/Abstract/Clauses.pm +++ b/lib/SQL/Abstract/Clauses.pm @@ -26,13 +26,8 @@ sub register_defaults { $self->{clauses_of}{delete} = [ qw(delete_from where returning) ]; $self->{expand}{delete} = sub { shift->_expand_statement(@_) }; $self->{render}{delete} = sub { shift->_render_statement(delete => @_) }; - $self->{expand_clause}{'delete.delete_from'} = sub { - $_[0]->_expand_maybe_list_expr($_[1], -ident) - }; - $self->{expand_clause}{'delete.where'} = 'expand_expr'; - $self->{expand_clause}{'delete.returning'} = sub { - shift->_expand_maybe_list_expr(@_, -ident); - }; + $self->{expand_clause}{"delete.$_"} = "_expand_delete_clause_$_" + for @{$self->{clauses_of}{delete}}; $self->{clauses_of}{insert} = [ 'insert_into', 'fields', 'values', 'returning' ]; @@ -87,6 +82,16 @@ sub _expand_update_clause_returning { +(returning => shift->_expand_maybe_list_expr(@_, -ident)); } +sub _expand_delete_clause_delete_from { + +(delete_from => shift->_expand_maybe_list_expr(@_, -ident)); +} + +sub _expand_delete_clause_where { +(where => shift->expand_expr(@_)); } + +sub _expand_delete_clause_returning { + +(returning => shift->_expand_maybe_list_expr(@_, -ident)); +} + sub _expand_statement { my ($self, $type, $args) = @_; my $ec = $self->{expand_clause};