Skip Menu |

This queue is for tickets about the DBIx-Class CPAN distribution.

Report information
The Basics
Id: 78456
Status: resolved
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: sb10 [...] sanger.ac.uk
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.08198
Fixed in: 0.08200



Subject: prefetch not working
See attached file for complete demonstration with all needed files. Basically, I do this: my @des = $schema->resultset('Dataelementstate')->search({ ... }, { join => 'dataelement', prefetch => 'dataelement' }); my $estate = $des[0]; my $element = $estate->dataelement; In 0.08192 and 0.08196 (the only 2 older versions I've used) this works as expected, and $element is a defined instance. In 0.08198 $element is undef. My test script output (in the attached file) shows that the SQL generated is the same for 0.08198 and 0.08192, but 0.08198 does not fill in the $estate->{related_resultsets}->{dataelement}->{all_cache} array, and $estate->{_inflated_column}->{dataelement} is undef. Removing the prefetch from the search lets $estate->dataelement return the object normally in 0.08198. But with the prefetch, 0.08198 prevents you getting the dataelement instance.
Subject: dbix_class_bug_report.tar.gz
Download dbix_class_bug_report.tar.gz
application/x-gzip 4.4k

Message body not shown because it is not plain text.

If you prefetch a relationship you don't have to also join it. Maybe the new version is stricter. Please remove the join and test it again.
On Thu Jul 19 08:14:43 2012, ABRAXXA wrote: Show quoted text
> If you prefetch a relationship you don't have to also join it. > Maybe the new version is stricter. > Please remove the join and test it again.
Removing the join does not alter anything.
I have no MySQL for testing here, can you change your tests to use SQLite? Are you sure the data in your db is what you expect it? You insert into Datasource and assume it gets the id 1 which you use for the following related inserts. Either use $ds->id instead of the hardcoded 1 or $ds->create_related. Also check what the query returns if you execute it manually.
On Thu Jul 19 08:29:34 2012, ABRAXXA wrote: Show quoted text
> I have no MySQL for testing here, can you change your tests to use SQLite?
Attached. Anyone else can change line 13 of modules/VRPipeTest.pm to choose database connection details. Show quoted text
> Are you sure the data in your db is what you expect it?
The test setup drops tables and recreates everything every time it is run. Show quoted text
> You insert into > Datasource and assume it gets the id 1 which you use for the following > related inserts.
This doesn't really matter, since I have a test that checks I got a Dataelementstate from my search() query. So everything before that must have been fine. Show quoted text
> Either use $ds->id instead of the hardcoded 1
I've done this in any case for the avoidance of doubt. I've also added a 4th test that does: my $direct = $schema->resultset('Dataelement')->find({ id => $estate->{_column_data}->{dataelement} }); I show that in 0.08198, $estate->dataelement returns undef while $direct exists. That is, $estate has the correct information about what dataelement it is supposed to return, and that dataelement can be retrieved directly with a find (so it is in the database), but there is some bug that prevents the dataelement() method working.
Subject: dbix_class_bug_report_sqlite.tar.gz

Message body not shown because it is not plain text.

Thanks, that was quick! You ask dbic for completed_steps > 1 but in the sqlite db its 0. I have no idea why a row is returned by the query: SELECT me.pipelinesetup, me.dataelement, me.id, me.completed_steps, dataelement.withdrawn, dataelement.id, dataelement.result, dataelement.datasource FROM dataelementstate me JOIN dataelement dataelement ON dataelement.id = me.dataelement WHERE me.completed_steps < '1' AND dataelement.withdrawn = '0' AND pipelinesetup = '1'
For get it, you ask for < 1, not > 1. I'll continue looking into it.
FYI: I'm seeing the same problem with SQLite. Starting with DBIx-Class 0.08198, some searches with the "prefetch" attribute do not populate the related objects, even though it does produce the right query. By just taking random shots in the dark, I've noticed that it seems to work when the prefetch value is a HashRef, but not when it is a scalar or ArrayRef. Hope that helps some. I'll send an isolated test case as soon as I am able. -Jeff
All, Please try the dev release 0.08198_01 and let us know if it fixes your issues. Jess On Tue Jul 24 02:04:29 2012, THALJEF wrote: Show quoted text
> FYI: I'm seeing the same problem with SQLite. Starting with DBIx-Class > 0.08198, some searches with the "prefetch" attribute do not populate
the Show quoted text
> related objects, even though it does produce the right query. By just > taking random shots in the dark, I've noticed that it seems to work
when Show quoted text
> the prefetch value is a HashRef, but not when it is a scalar or
ArrayRef. Show quoted text
> > Hope that helps some. I'll send an isolated test case as soon as I
am able. Show quoted text
> > -Jeff
On Wed Jul 25 16:44:02 2012, JROBINSON wrote: Show quoted text
> All, > > Please try the dev release 0.08198_01 and let us know if it fixes your > issues.
Thanks, I can confirm that the rollback in 0.08198_01 fixes the issue (or at least, my tests now pass).
On Wed Jul 25 13:44:02 2012, JROBINSON wrote: Show quoted text
> Please try the dev release 0.08198_01 and let us know if it fixes your > issues.
I can confirm that 0.8198_01 seems to fix the problem (for me, at least). Thanks for helping us out. -Jeff
From: jns [...] gellyfish.co.uk
Hi, I was just beginning to suspect that the regression in our tests was a bug elsewhere too :) This fixed problem with prefetching for us too. On Wed Jul 25 16:44:02 2012, JROBINSON wrote: Show quoted text
> All, > > Please try the dev release 0.08198_01 and let us know if it fixes your > issues. > > Jess > > On Tue Jul 24 02:04:29 2012, THALJEF wrote:
> > FYI: I'm seeing the same problem with SQLite. Starting with DBIx-
Class Show quoted text
> > 0.08198, some searches with the "prefetch" attribute do not populate
> the
> > related objects, even though it does produce the right query. By
just Show quoted text
> > taking random shots in the dark, I've noticed that it seems to work
> when
> > the prefetch value is a HashRef, but not when it is a scalar or
> ArrayRef.
> > > > Hope that helps some. I'll send an isolated test case as soon as I
> am able.
> > > > -Jeff
>
Fixed in 0.08200, sorry for the delays.