X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSQLMaker.pm;h=ea2b23ed631c67d3e4e107ee4a8618fa57a19d8e;hb=f3e9f0106fd3a446938e1a981704278922fcab2d;hp=d0fbc7790833752d8b89923e94d29678ef78aa09;hpb=d5dedbd62928f65a9071b4d9b6d56c6b663a073b;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/SQLMaker.pm b/lib/DBIx/Class/SQLMaker.pm index d0fbc77..ea2b23e 100644 --- a/lib/DBIx/Class/SQLMaker.pm +++ b/lib/DBIx/Class/SQLMaker.pm @@ -54,7 +54,7 @@ BEGIN { *{"SQL::Abstract::$f"} = subname "SQL::Abstract::$f" => sub { if (Carp::longmess() =~ /DBIx::Class::SQLMaker::[\w]+ .+? called \s at/x) { - $clan_import->(@_); + goto $clan_import; } else { goto $orig; @@ -121,6 +121,9 @@ sub select { # this *must* be called, otherwise extra binds will remain in the sql-maker my @all_bind = $self->_assemble_binds; + $sql .= $self->_lock_select ($rs_attrs->{for}) + if $rs_attrs->{for}; + return wantarray ? ($sql, @all_bind) : $sql; } @@ -129,6 +132,16 @@ sub _assemble_binds { return map { @{ (delete $self->{"${_}_bind"}) || [] } } (qw/from where having order/); } +my $for_syntax = { + update => 'FOR UPDATE', + shared => 'FOR SHARE', +}; +sub _lock_select { + my ($self, $type) = @_; + my $sql = $for_syntax->{$type} || croak "Unknown SELECT .. FOR type '$type' requested"; + return " $sql"; +} + # Handle default inserts sub insert { # optimized due to hotttnesss @@ -198,10 +211,6 @@ sub _recurse_fields { } } -my $for_syntax = { - update => 'FOR UPDATE', - shared => 'FOR SHARE', -}; # this used to be a part of _order_by but is broken out for clarity. # What we have been doing forever is hijacking the $order arg of @@ -230,10 +239,6 @@ sub _parse_rs_attrs { $sql .= $self->_order_by ($arg->{order_by}); } - if (my $for = $arg->{for}) { - $sql .= " $for_syntax->{$for}" if $for_syntax->{$for}; - } - return $sql; }