[Dbix-class] How to debug?

Paul Mooney paul.mooney at phymatics.co.uk
Fri Apr 22 11:09:04 GMT 2016


Hello,

I have a bug that happens /sometimes/. Replicating it is a pain.
I would like advice on how to debug it...
Because I'm scratching my head.

If I run our full test suite (takes about 20 minutes) I sometimes get 
JOINs where there should not be JOINs. It's like something has been 
cached somewhere and it's remembering a previous query... but I can't 
see how they is possible...

My code is inside a Result class. It looks like this:

   my @some_items = 
$self->result_source->schema->resultset("FulfilmentItem")->search({fulfilment_item_status_id 
=> { -in => [5,9,69696969] } })->all;

But sometimes I get SQL generated *with JOINs*... WTF?:

SELECT me.id, <more_fields>
FROM fulfilment_item me
JOIN fulfilment fulfilment ON fulfilment.id = me.fulfilment_id
LEFT JOIN mts_hook mts_hook ON mts_hook.fulfilment_item_id = me.id
WHERE ( ( ( fulfilment.allocation_id = ? OR fulfilment.allocation_id = ? 
OR fulfilment.allocation_id = ? OR fulfilment.allocation_id = ? ) AND 
fulfilment_item_status_id IN ( ?, ?, ? ) ) )
: 'taBE4E1BE6-07D9-11E6-9001-984A2B909FEA', 
'taBF55B3A0-07D9-11E6-9001-984A2B909FEA', 
'taC09556B2-07D9-11E6-9001-984A2B909FEA', 
'taC1DCBE98-07D9-11E6-9001-984A2B909FEA', '5', '9', '69696969'

If I run the test on its own there are no JOINs.

perl v5.20.3
DBIx::Class::VERSION = 0.082820

Any ideas?
All advice welcome.




More information about the DBIx-Class mailing list