Commit | Line | Data |
a48693f4 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
5 | use lib qw(t/lib); |
6 | use DBICTest; |
7 | use PrefetchBug; |
8 | |
9 | BEGIN { |
10 | require DBIx::Class; |
11 | plan skip_all => 'Test needs ' . |
12 | DBIx::Class::Optional::Dependencies->req_missing_for('deploy') |
13 | unless DBIx::Class::Optional::Dependencies->req_ok_for('deploy'); |
14 | } |
15 | |
16 | my $schema |
17 | = PrefetchBug->connect( DBICTest->_database (quote_char => '"') ); |
18 | ok( $schema, 'Connected to PrefetchBug schema OK' ); |
19 | |
20 | #################### DEPLOY |
21 | |
22 | $schema->deploy( { add_drop_table => 1 } ); |
23 | |
24 | # Test simple has_many prefetch: |
25 | |
26 | my $leftc = $schema->resultset('Left')->create({}); |
27 | my $rightc = $schema->resultset('Right')->create({ id => 60, name => 'Johnny', category => 'something', description=> 'blah', propagates => 0, locked => 1 }); |
28 | $rightc->create_related('prefetch_leftright', { left => $leftc, value => 'lr' }); |
29 | |
30 | # start with fresh whatsit |
31 | my $left = $schema->resultset('Left')->find({ id => $leftc->id }); |
32 | |
33 | my @left_rights = $left->search_related('prefetch_leftright', {}, { prefetch => 'right' }); |
34 | ok(defined $left_rights[0]->right, 'Prefetched Right side correctly'); |
35 | |
36 | done_testing; |