From: Matt S Trout Date: Tue, 16 Apr 2019 03:48:34 +0000 (+0000) Subject: clean up calling convention X-Git-Tag: v2.000000~3^2~222 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6c39a2f7ab105d35ec9ccda184b935324d92c7b7;p=dbsrgits%2FSQL-Abstract.git clean up calling convention --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 1ed3dc7..326fd0d 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -530,7 +530,7 @@ sub render_aqt { die "No" if @rest; die "Not a node type: $k" unless $k =~ s/^-//; if (my $meth = $self->{render}{$k}) { - return $self->$meth($v); + return $self->$meth($k, $v); } die "notreached: $k"; } @@ -1068,19 +1068,19 @@ sub _recurse_where { } sub _render_ident { - my ($self, $ident) = @_; + my ($self, undef, $ident) = @_; return $self->_convert($self->_quote($ident)); } sub _render_row { - my ($self, $values) = @_; - my ($sql, @bind) = $self->_render_op([ ',', @$values ]); + my ($self, undef, $values) = @_; + my ($sql, @bind) = $self->_render_op(undef, [ ',', @$values ]); return "($sql)", @bind; } sub _render_func { - my ($self, $rest) = @_; + my ($self, undef, $rest) = @_; my ($func, @args) = @$rest; if (ref($func) eq 'HASH') { $func = $self->render_aqt($func); @@ -1095,18 +1095,18 @@ sub _render_func { } sub _render_bind { - my ($self, $bind) = @_; + my ($self, undef, $bind) = @_; return ($self->_convert('?'), $self->_bindtype(@$bind)); } sub _render_literal { - my ($self, $literal) = @_; + my ($self, undef, $literal) = @_; $self->_assert_bindval_matches_bindtype(@{$literal}[1..$#$literal]); return @$literal; } sub _render_op { - my ($self, $v) = @_; + my ($self, undef, $v) = @_; my ($op, @args) = @$v; if (my $r = $self->{render_op}{$op}) { return $self->$r($op, \@args); diff --git a/lib/SQL/Abstract/Clauses.pm b/lib/SQL/Abstract/Clauses.pm index 18626c2..fc36e74 100644 --- a/lib/SQL/Abstract/Clauses.pm +++ b/lib/SQL/Abstract/Clauses.pm @@ -16,12 +16,12 @@ sub register_defaults { my ($self) = @_; $self->{clauses_of}{select} = [ qw(select from where order_by) ]; $self->{expand}{select} = sub { shift->_expand_statement(@_) }; - $self->{render}{select} = sub { shift->_render_statement(select => @_) }; + $self->{render}{select} = sub { shift->_render_statement(@_) }; $self->{expand_clause}{"select.$_"} = "_expand_select_clause_$_" for @{$self->{clauses_of}{select}}; $self->{clauses_of}{update} = [ qw(target set where returning) ]; $self->{expand}{update} = sub { shift->_expand_statement(@_) }; - $self->{render}{update} = sub { shift->_render_statement(update => @_) }; + $self->{render}{update} = sub { shift->_render_statement(@_) }; $self->{expand_clause}{"update.$_"} = "_expand_update_clause_$_" for @{$self->{clauses_of}{update}}; $self->{expand_clause}{'update.update'} = '_expand_update_clause_target'; @@ -32,7 +32,7 @@ sub register_defaults { }; $self->{clauses_of}{delete} = [ qw(target where returning) ]; $self->{expand}{delete} = sub { shift->_expand_statement(@_) }; - $self->{render}{delete} = sub { shift->_render_statement(delete => @_) }; + $self->{render}{delete} = sub { shift->_render_statement(@_) }; $self->{expand_clause}{"delete.$_"} = "_expand_delete_clause_$_" for @{$self->{clauses_of}{delete}}; $self->{expand_clause}{"delete.from"} = '_expand_delete_clause_target'; @@ -45,7 +45,7 @@ sub register_defaults { 'target', 'fields', 'from', 'returning' ]; $self->{expand}{insert} = sub { shift->_expand_statement(@_) }; - $self->{render}{insert} = sub { shift->_render_statement(insert => @_) }; + $self->{render}{insert} = sub { shift->_render_statement(@_) }; $self->{expand_clause}{'insert.into'} = '_expand_insert_clause_target'; $self->{expand_clause}{'insert.target'} = '_expand_insert_clause_target'; $self->{expand_clause}{'insert.fields'} = sub { @@ -263,7 +263,7 @@ sub _expand_values { } sub _render_values { - my ($self, $values) = @_; + my ($self, undef, $values) = @_; my ($v_sql, @bind) = $self->join_clauses( ', ', map [ $self->render_aqt($_) ], diff --git a/lib/SQL/Abstract/ExtraClauses.pm b/lib/SQL/Abstract/ExtraClauses.pm index f471794..c055b8b 100644 --- a/lib/SQL/Abstract/ExtraClauses.pm +++ b/lib/SQL/Abstract/ExtraClauses.pm @@ -92,7 +92,7 @@ sub register_defaults { foreach my $setop (qw(union intersect except)) { $self->renderer($setop => sub { - my ($self, $args) = @_; + my ($self, undef, $args) = @_; $self->join_clauses( ' '.$self->format_keyword(join '_', $setop, ($args->{type}||())).' ', map [ $self->render_aqt($_) ], @{$args->{queries}} @@ -219,12 +219,12 @@ sub _expand_join { } sub _render_from_list { - my ($self, $list) = @_; + my ($self, undef, $list) = @_; return $self->join_clauses(', ', map [ $self->render_aqt($_) ], @$list); } sub _render_join { - my ($self, $args) = @_; + my ($self, undef, $args) = @_; my @parts = ( [ $self->render_aqt($args->{from}) ], @@ -252,7 +252,7 @@ sub _expand_op_as { } sub _render_as { - my ($self, $args) = @_; + my ($self, undef, $args) = @_; my ($thing, @alias) = @$args; return $self->join_clauses( ' ',