From: Peter Rabbitson Date: Sat, 15 May 2010 15:50:57 +0000 (+0000) Subject: Fix stupid typo-bug X-Git-Tag: v0.08122~68 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fef47a8e19fdafd3f039a6c2494d2e8051b3faef;p=dbsrgits%2FDBIx-Class.git Fix stupid typo-bug --- diff --git a/Changes b/Changes index 94576fa..a6ba126 100644 --- a/Changes +++ b/Changes @@ -20,10 +20,12 @@ Revision history for DBIx::Class the unsafe_subselect_ok attribute, due to optimized queries - Fix as_subselect_rs to not inject resultset class-wide where conditions outside of the resulting subquery + - Fix nasty potentially data-eating bug when deleting/updating + a limited resultset - Depend on optimized SQL::Abstract (faster SQL generation) - - update on row not in database now OK if no changes - - fixes problems with cascaded unnecessary updates - + - update() on row not in_storage no longer throws an exception + if there are no dirty columns to update (fixes cascaded update + annoyances) 0.08121 2010-04-11 18:43:00 (UTC) - Support for Firebird RDBMS with DBD::InterBase and ODBC diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 7ac07ca..1dc4068 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -1424,7 +1424,7 @@ sub _rs_update_delete { my $cond = $rsrc->schema->storage->_strip_cond_qualifiers ($self->{cond}); my $needs_group_by_subq = $self->_has_resolved_attr (qw/collapse group_by -join/); - my $needs_subq = $needs_group_by_subq || (not defined $cond) || $self->_has_resolved_attr(qw/row offset/); + my $needs_subq = $needs_group_by_subq || (not defined $cond) || $self->_has_resolved_attr(qw/rows offset/); if ($needs_group_by_subq or $needs_subq) { diff --git a/t/resultset/update_delete.t b/t/resultset/update_delete.t index 05d245b..542ea07 100644 --- a/t/resultset/update_delete.t +++ b/t/resultset/update_delete.t @@ -6,9 +6,6 @@ use Test::More; use Test::Exception; use DBICTest; -#plan tests => 5; -plan 'no_plan'; - my $schema = DBICTest->init_schema(); my $tkfks = $schema->resultset('FourKeys_to_TwoKeys'); @@ -110,3 +107,10 @@ is_deeply ( $sub_rs->delete; is ($tkfks->count, $tkfk_cnt -= 2, 'Only two rows deleted'); + +# make sure limit-only deletion works +cmp_ok ($tkfk_cnt, '>', 1, 'More than 1 row left'); +$tkfks->search ({}, { rows => 1 })->delete; +is ($tkfks->count, $tkfk_cnt -= 1, 'Only one row deleted'); + +done_testing;