Factor out bindattr resolver and tighten code a bit
[dbsrgits/DBIx-Class.git] / t / sqlmaker / msaccess.t
CommitLineData
726c8f65 1use strict;
2use warnings;
3use Test::More;
4use lib qw(t/lib);
5use DBICTest;
6use DBIC::SqlMakerTest;
7
696ba760 8use DBIx::Class::SQLMaker::ACCESS ();
726c8f65 9
10my $sa = DBIx::Class::SQLMaker::ACCESS->new;
11
12# my ($self, $table, $fields, $where, $order, @rest) = @_;
13my ($sql, @bind) = $sa->select(
14 [
15 { me => "cd" },
16 [
17 { "-join_type" => "LEFT", artist => "artist" },
18 { "artist.artistid" => "me.artist" },
19 ],
20 ],
21 [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
22 undef,
23 undef
24);
25is_same_sql_bind(
26 $sql, \@bind,
27 'SELECT cd.cdid, cd.artist, cd.title, cd.year, artist.artistid, artist.name FROM (cd me LEFT JOIN artist artist ON artist.artistid = me.artist)', [],
28 'one-step join parenthesized'
29);
30
31($sql, @bind) = $sa->select(
32 [
33 { me => "cd" },
34 [
35 { "-join_type" => "LEFT", track => "track" },
36 { "track.cd" => "me.cdid" },
37 ],
38 [
696ba760 39 { artist => "artist" },
726c8f65 40 { "artist.artistid" => "me.artist" },
41 ],
42 ],
43 [ 'track.title', 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
44 undef,
45 undef
46);
47is_same_sql_bind(
48 $sql, \@bind,
696ba760 49 'SELECT track.title, cd.cdid, cd.artist, cd.title, cd.year, artist.artistid, artist.name FROM ((cd me LEFT JOIN track track ON track.cd = me.cdid) INNER JOIN artist artist ON artist.artistid = me.artist)', [],
50 'two-step join parenthesized and inner join prepended with INNER'
726c8f65 51);
52
53done_testing;