6 use DBICTest ':DiffSQL';
7 use DBIx::Class::_Util 'sigwarn_silencer';
9 use DBIx::Class::SQLMaker;
10 my $sa = DBIx::Class::SQLMaker->new;
12 $SIG{__WARN__} = sigwarn_silencer( qr/\Q{from} structures with conditions not conforming to the SQL::Abstract syntax are deprecated/ );
15 { child => 'person' },
16 [ { father => 'person' }, { 'father.person_id' => 'child.father_id' }, ],
17 [ { mother => 'person' }, { 'mother.person_id' => 'child.mother_id' } ],
19 my $match = 'person child JOIN person father ON ( father.person_id = '
20 . 'child.father_id ) JOIN person mother ON ( mother.person_id '
21 . '= child.mother_id )'
24 $sa->_recurse_from(@j),
30 { mother => 'person' },
31 [ [ { child => 'person' },
32 [ { father => 'person' },
33 { 'father.person_id' => 'child.father_id' }
36 { 'mother.person_id' => 'child.mother_id' }
39 $match = 'person mother JOIN (person child JOIN person father ON ('
40 . ' father.person_id = child.father_id )) ON ( mother.person_id = '
44 $sa->_recurse_from(@j2),
50 { child => 'person' },
51 [ { father => 'person', -join_type => 'inner' }, { 'father.person_id' => 'child.father_id' }, ],
52 [ { mother => 'person', -join_type => 'inner' }, { 'mother.person_id' => 'child.mother_id' } ],
54 $match = 'person child INNER JOIN person father ON ( father.person_id = '
55 . 'child.father_id ) INNER JOIN person mother ON ( mother.person_id '
56 . '= child.mother_id )'
60 $sa->_recurse_from(@j3),
62 'join 3 (inner join) ok'
66 { mother => 'person' },
67 [ [ { child => 'person', -join_type => 'left' },
68 [ { father => 'person', -join_type => 'right' },
69 { 'father.person_id' => 'child.father_id' }
72 { 'mother.person_id' => 'child.mother_id' }
75 $match = 'person mother LEFT JOIN (person child RIGHT JOIN person father ON ('
76 . ' father.person_id = child.father_id )) ON ( mother.person_id = '
80 $sa->_recurse_from(@j4),
82 'join 4 (nested joins + join types) ok'
86 { child => 'person' },
87 [ { father => 'person' }, { 'father.person_id' => \'!= child.father_id' }, ],
88 [ { mother => 'person' }, { 'mother.person_id' => 'child.mother_id' } ],
90 $match = 'person child JOIN person father ON ( father.person_id != '
91 . 'child.father_id ) JOIN person mother ON ( mother.person_id '
92 . '= child.mother_id )'
95 $sa->_recurse_from(@j5),
97 'join 5 (SCALAR reference for ON statement) ok'