X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI.pm;h=e8c9bb2e7f80d2f7440deb5c41a995c803c83cdc;hp=9fbcc97aae5773eb68475e8339e1bf0a98336102;hb=af668ad64b95ab8d84343a4738a7ce65e068f3f3;hpb=10176e1f9feac3f33603fd385a301c9d94de59fc diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 9fbcc97..e8c9bb2 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1549,20 +1549,35 @@ sub _dbh_execute_inserts_with_no_binds { } sub update { - my ($self, $source, @args) = @_; + my ($self, $source, $data, $where, @args) = @_; - my $bind_attributes = $self->source_bind_attributes($source); + my $bind_attrs = $self->source_bind_attributes($source); + $where = $self->_strip_cond_qualifiers ($where); - return $self->_execute('update' => [], $source, $bind_attributes, @args); + return $self->_execute('update' => [], $source, $bind_attrs, $data, $where, @args); } sub delete { - my ($self, $source, @args) = @_; + my ($self, $source, $where, @args) = @_; my $bind_attrs = $self->source_bind_attributes($source); + $where = $self->_strip_cond_qualifiers ($where); + + return $self->_execute('delete' => [], $source, $bind_attrs, $where, @args); +} + +sub _strip_cond_qualifiers { + my ($self, $where) = @_; + + my $sqlmaker = $self->sql_maker; + my ($sql, @bind) = $sqlmaker->_recurse_where($where); + return undef unless $sql; + + my ($qquot, $qsep) = map { quotemeta $_ } ( ($sqlmaker->quote_char||''), ($sqlmaker->name_sep||'.') ); + $sql =~ s/ (?: $qquot [\w\-]+ $qquot | [\w\-]+ ) $qsep //gx; - return $self->_execute('delete' => [], $source, $bind_attrs, @args); + return \[$sql, @bind]; } # We were sent here because the $rs contains a complex search