From: Peter Rabbitson Date: Tue, 26 May 2009 15:20:57 +0000 (+0000) Subject: Minor fixes of the return value of rs->update/delete X-Git-Tag: v0.08103~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=194311161bdbebd2402c457ded300fc83b773f02;p=dbsrgits%2FDBIx-Class.git Minor fixes of the return value of rs->update/delete --- diff --git a/Changes b/Changes index af51dae..71ecbd8 100644 --- a/Changes +++ b/Changes @@ -4,6 +4,8 @@ Revision history for DBIx::Class of these operations will succeed, regardless of the complexity of $resultset. distinct, group_by, join, prefetch are all supported with expected results + - Return value of $rs->delete is now the storage return value + and not 1 as it used to be - don't pass SQL functions into GROUP BY - Remove MultiDistinctEmulation.pm, effectively deprecating { select => { distinct => [ qw/col1 col2/ ] } } @@ -33,6 +35,7 @@ Revision history for DBIx::Class correctly (RT#28451) - "timestamp with time zone" columns (for Pg) now get inflated with a time zone information preserved + - MSSQL Top limit-emulation improvements (GROUP BY and subquery support) 0.08102 2009-04-30 08:29:00 (UTC) - Fixed two subtle bugs when using columns or select/as diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 5a8595c..282651f 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -1527,7 +1527,7 @@ sub update_all { =item Arguments: none -=item Return Value: 1 +=item Return Value: $storage_rv =back @@ -1535,11 +1535,8 @@ Deletes the contents of the resultset from its result source. Note that this will not run DBIC cascade triggers. See L if you need triggers to run. See also L. -delete may not generate correct SQL for a query with joins or a resultset -chained from a related resultset. In this case it will generate a warning:- - -In these cases you may find that delete_all is more appropriate, or you -need to respecify your query in a way that can be expressed without a join. +Return value will be the amount of rows deleted; exact type of return value +is storage-dependent. =cut diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 9f38504..0b244d4 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1144,6 +1144,7 @@ sub _per_row_update_delete { my $guard = $self->txn_scope_guard; my $subrs_cur = $rs->cursor; + my $row_cnt = '0E0'; while (my @pks = $subrs_cur->next) { my $cond; @@ -1156,11 +1157,13 @@ sub _per_row_update_delete { $op eq 'update' ? $values : (), $cond, ); + + $row_cnt++; } $guard->commit; - return 1; + return $row_cnt; } sub _select {