X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=blobdiff_plain;f=t%2Fresultset%2Fupdate_delete.t;h=5cd7071b38bce143594d1bb2de8d671d5afde62e;hp=542ea073ce54c2d1377d445a1b749f0cdb1e6707;hb=887d8da0864e028f457ce5c6abaccb2d7160698b;hpb=697d7cd9163e9778c36dfb69b2da6625e8017020 diff --git a/t/resultset/update_delete.t b/t/resultset/update_delete.t index 542ea07..5cd7071 100644 --- a/t/resultset/update_delete.t +++ b/t/resultset/update_delete.t @@ -5,6 +5,8 @@ use lib qw(t/lib); use Test::More; use Test::Exception; use DBICTest; +use DBIC::DebugObj; +use DBIC::SqlMakerTest; my $schema = DBICTest->init_schema(); @@ -105,7 +107,6 @@ is_deeply ( ); $sub_rs->delete; - is ($tkfks->count, $tkfk_cnt -= 2, 'Only two rows deleted'); # make sure limit-only deletion works @@ -113,4 +114,26 @@ 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'); + +# Make sure prefetch is properly stripped too +# check with sql-equality, as sqlite will accept bad sql just fine +my ($sql, @bind); +my $orig_debugobj = $schema->storage->debugobj; +my $orig_debug = $schema->storage->debug; + +$schema->storage->debugobj (DBIC::DebugObj->new (\$sql, \@bind) ); +$schema->storage->debug (1); +$schema->resultset('CD')->search( + { year => { '!=' => 2010 } }, + { prefetch => 'liner_notes' }, +)->delete; + +is_same_sql_bind ( + $sql, + \@bind, + 'DELETE FROM cd WHERE ( cdid IN ( SELECT me.cdid FROM cd me WHERE ( year != ? ) GROUP BY me.cdid ) )', + ["'2010'"], + 'Update on prefetching resultset strips prefetch correctly' +); + done_testing;