1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
8 use DBICTest ':DiffSQL';
9 use DBIx::Class::_Util 'sigwarn_silencer';
11 use DBIx::Class::SQLMaker;
12 my $sa = DBIx::Class::SQLMaker->new;
14 $SIG{__WARN__} = sigwarn_silencer( qr/\Q{from} structures with conditions not conforming to the SQL::Abstract syntax are deprecated/ );
17 { child => 'person' },
18 [ { father => 'person' }, { 'father.person_id' => 'child.father_id' }, ],
19 [ { mother => 'person' }, { 'mother.person_id' => 'child.mother_id' } ],
21 my $match = 'person child JOIN person father ON ( father.person_id = '
22 . 'child.father_id ) JOIN person mother ON ( mother.person_id '
23 . '= child.mother_id )'
26 $sa->_recurse_from(@j),
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 = '
46 $sa->_recurse_from(@j2),
52 { child => 'person' },
53 [ { father => 'person', -join_type => 'inner' }, { 'father.person_id' => 'child.father_id' }, ],
54 [ { mother => 'person', -join_type => 'inner' }, { 'mother.person_id' => 'child.mother_id' } ],
56 $match = 'person child INNER JOIN person father ON ( father.person_id = '
57 . 'child.father_id ) INNER JOIN person mother ON ( mother.person_id '
58 . '= child.mother_id )'
62 $sa->_recurse_from(@j3),
64 'join 3 (inner join) ok'
68 { mother => 'person' },
69 [ [ { child => 'person', -join_type => 'left' },
70 [ { father => 'person', -join_type => 'right' },
71 { 'father.person_id' => 'child.father_id' }
74 { 'mother.person_id' => 'child.mother_id' }
77 $match = 'person mother LEFT JOIN (person child RIGHT JOIN person father ON ('
78 . ' father.person_id = child.father_id )) ON ( mother.person_id = '
82 $sa->_recurse_from(@j4),
84 'join 4 (nested joins + join types) ok'
88 { child => 'person' },
89 [ { father => 'person' }, { 'father.person_id' => \'!= child.father_id' }, ],
90 [ { mother => 'person' }, { 'mother.person_id' => 'child.mother_id' } ],
92 $match = 'person child JOIN person father ON ( father.person_id != '
93 . 'child.father_id ) JOIN person mother ON ( mother.person_id '
94 . '= child.mother_id )'
97 $sa->_recurse_from(@j5),
99 'join 5 (SCALAR reference for ON statement) ok'