6 use DBICTest ':DiffSQL';
8 use DBIx::Class::SQLMaker;
9 my $sa = DBIx::Class::SQLMaker->new;
12 { child => 'person' },
13 [ { father => 'person' }, { 'father.person_id' => 'child.father_id' }, ],
14 [ { mother => 'person' }, { 'mother.person_id' => 'child.mother_id' } ],
16 my $match = 'person child JOIN person father ON ( father.person_id = '
17 . 'child.father_id ) JOIN person mother ON ( mother.person_id '
18 . '= child.mother_id )'
21 $sa->_recurse_from(@j),
27 { mother => 'person' },
28 [ [ { child => 'person' },
29 [ { father => 'person' },
30 { 'father.person_id' => 'child.father_id' }
33 { 'mother.person_id' => 'child.mother_id' }
36 $match = 'person mother JOIN (person child JOIN person father ON ('
37 . ' father.person_id = child.father_id )) ON ( mother.person_id = '
41 $sa->_recurse_from(@j2),
47 { child => 'person' },
48 [ { father => 'person', -join_type => 'inner' }, { 'father.person_id' => 'child.father_id' }, ],
49 [ { mother => 'person', -join_type => 'inner' }, { 'mother.person_id' => 'child.mother_id' } ],
51 $match = 'person child INNER JOIN person father ON ( father.person_id = '
52 . 'child.father_id ) INNER JOIN person mother ON ( mother.person_id '
53 . '= child.mother_id )'
57 $sa->_recurse_from(@j3),
59 'join 3 (inner join) ok'
63 { mother => 'person' },
64 [ [ { child => 'person', -join_type => 'left' },
65 [ { father => 'person', -join_type => 'right' },
66 { 'father.person_id' => 'child.father_id' }
69 { 'mother.person_id' => 'child.mother_id' }
72 $match = 'person mother LEFT JOIN (person child RIGHT JOIN person father ON ('
73 . ' father.person_id = child.father_id )) ON ( mother.person_id = '
77 $sa->_recurse_from(@j4),
79 'join 4 (nested joins + join types) ok'
83 { child => 'person' },
84 [ { father => 'person' }, { 'father.person_id' => \'!= child.father_id' }, ],
85 [ { mother => 'person' }, { 'mother.person_id' => 'child.mother_id' } ],
87 $match = 'person child JOIN person father ON ( father.person_id != '
88 . 'child.father_id ) JOIN person mother ON ( mother.person_id '
89 . '= child.mother_id )'
92 $sa->_recurse_from(@j5),
94 'join 5 (SCALAR reference for ON statement) ok'