[Dbix-class] CDBICompat NumExplodingSheep

Dave Howorth dhoworth at mrc-lmb.cam.ac.uk
Tue Feb 3 16:11:24 GMT 2009


Peter Rabbitson wrote:
> I contacted the CDBI-compat shim maintainer and here is his reply. I also included
> him in the CC, please reply-all if you discuss it with him to keep me in the loop.

No need to copy me as long as the mailing list is included :)

> ==============================================================
> 
> Peter Rabbitson wrote:
>> Haven't seen you on IRC for a while, figured I'll try here. We got a
>> bugreport[1] against the compat layer some time ago. I applied his
>> indeed failing tests[2], and TODOified[3] them. If you can drop by to see
>> if this can/needs to be fixed it'd be great.
> 
> In general, I think you're right to do the full hash copy.
> 
> But I ran the new tests through CDBI and insert() doesn't appear to honor
> accessor_name_for() for the hash keys.  So this sort of thing doesn't work.

My brain hurts whenever I look at these issues and I haven't yet had
time to reproduce either my tests or this test. Though I did test with
CDBI when I wrote my extra tests.

But my initial reaction is confusion because the tests of insert()
(a.k.a. create() ) were not added by me. They are the original tests and
they were working. Further, the code for sub insert in CDBI has lines of
code like this:

  my $col = $class->find_column($k)
	|| (List::Util::first { $_->mutator  eq $k } $class->columns)
	|| (List::Util::first { $_->accessor eq $k } $class->columns)
	|| $class->_croak("$k is not a column of $class");

So I'm very surprised accessors aren't working.

I'll try to setup my environment to reproduce the tests but it always
takes me a while to get it right :(

Cheers, Dave

> eval {
> 	my $data = { %$data };
> 	$data->{sheep} = 2;
> 	ok my $bt = Film->insert($data), "Modified accessor - with accessor";
> 	isa_ok $bt, "Film";
>         is $bt->sheep, 2, 'sheep bursting violently';
> };
> is $@, '', "No errors";
> 
> Whether this is a bug or feature of CDBI is arguable, insert() and the
> accessors have always been a little out of sync, but as far as CDBI::Compat is
> concerned just go with what CDBI actually does.
> 
> So those new tests should probably be pulled.
> 
> 




More information about the DBIx-Class mailing list