13 my ($got, $expect, $msg) = @_;
14 ok($got eq $expect) or
15 warn "got [${got}]\ninstead of [${expect}]\nfor test ${msg}\n\n";
18 my $sa = new SQL::Abstract;
21 { child => 'person' },
22 [ { father => 'person' }, { 'father.person_id' => 'child.father_id' }, ],
23 [ { mother => 'person' }, { 'mother.person_id' => 'child.mother_id' } ],
25 my $match = 'person child JOIN person father ON ( father.person_id = '
26 . 'child.father_id ) JOIN person mother ON ( mother.person_id '
27 . '= child.mother_id )'
29 is( $sa->_recurse_from(@j), $match, 'join 1 ok' );
32 { mother => 'person' },
33 [ [ { child => 'person' },
34 [ { father => 'person' },
35 { 'father.person_id' => 'child.father_id' }
38 { 'mother.person_id' => 'child.mother_id' }
41 $match = 'person mother JOIN (person child JOIN person father ON ('
42 . ' father.person_id = child.father_id )) ON ( mother.person_id = '
45 is( $sa->_recurse_from(@j2), $match, 'join 2 ok' );
48 { child => 'person' },
49 [ { father => 'person', -join_type => 'inner' }, { 'father.person_id' => 'child.father_id' }, ],
50 [ { mother => 'person', -join_type => 'inner' }, { 'mother.person_id' => 'child.mother_id' } ],
52 $match = 'person child INNER JOIN person father ON ( father.person_id = '
53 . 'child.father_id ) INNER JOIN person mother ON ( mother.person_id '
54 . '= child.mother_id )'
57 is( $sa->_recurse_from(@j3), $match, 'join 3 (inner join) ok');
60 { mother => 'person' },
61 [ [ { child => 'person', -join_type => 'left' },
62 [ { father => 'person', -join_type => 'right' },
63 { 'father.person_id' => 'child.father_id' }
66 { 'mother.person_id' => 'child.mother_id' }
69 $match = 'person mother LEFT JOIN (person child RIGHT JOIN person father ON ('
70 . ' father.person_id = child.father_id )) ON ( mother.person_id = '
73 is( $sa->_recurse_from(@j4), $match, 'join 4 (nested joins + join types) ok');