[Dbix-class] cascade delete problem

Matt S Trout dbix-class at trout.me.uk
Fri Mar 31 20:17:30 CEST 2006


Richard Jolly wrote:
> 
> On 30 Mar 2006, at 12:14, Richard Jolly wrote:
> 
>> I have a simple cascade delete test that fails under 6.0 but passed 
>> under 5.007.
> 
> I've written this as a failing test against trunk.  I'd expect its 
> something I've misunderstood rather than a real bug, but here it is 
> anyway. Inline as a patch, and two files attached in case I've got the 
> patch wrong.
> 
> Richard
> 
> 
> 
> ==== Patch <cascade_delete> level 1
> Source: [No source]
> Target: 58e6d779-1806-0410-870b-b3f1ff428cff:/local/dbix-class/t:7330 
> [local]
> Log:
> cascade_delete test
> === basicrels/26cascade_delete.t
> ==================================================================
> --- basicrels/26cascade_delete.t        (revision 7330)
> +++ basicrels/26cascade_delete.t        (patch cascade_delete level 1)
> @@ -0,0 +1,7 @@
> +use Test::More;
> +use lib qw(t/lib);
> +use DBICTest;
> +use DBICTest::BasicRels;
> +
> +require "t/run/26cascade_delete.tl";
> +run_tests(DBICTest->schema);
> === run/26cascade_delete.tl
> ==================================================================
> --- run/26cascade_delete.tl     (revision 7330)
> +++ run/26cascade_delete.tl     (patch cascade_delete level 1)
> @@ -0,0 +1,15 @@
> +use strict;
> +use warnings;
> +
> +sub run_tests {
> +my $schema = shift;
> +
> +plan tests => 2;
> +my $artist = $schema->resultset('Artist')->find(1);
> +
> +$artist->delete;
> +is( $schema->resultset('Artist')->count, 0, 'artist deleted');
> +is( $schema->resultset('CD')->search({artist => 1})->count, 0, 'related 
> cds deleted');
> +
> +}
> +1;

Erm. The first part of that test fails because there's more than one artist 
setup for the test suite. The second test passes fine though -

1..2
SELECT me.artistid, me.name FROM artist me WHERE ( me.artistid = ? ): `1'
DELETE FROM artist WHERE ( artistid = ? ): `1'
DELETE FROM cd WHERE ( artist = ? ): `1'
SELECT COUNT( * ) FROM artist me:
not ok 1 - artist deleted
#   Failed test 'artist deleted'
#   in t/run/26cascade_delete.tl at line 11.
#          got: '2'
#     expected: '0'
SELECT COUNT( * ) FROM cd me WHERE ( artist = ? ): `1'
ok 2 - related cds deleted
# Looks like you failed 1 test of 2.


-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Dbix-class mailing list