Merge branch 'master' into topic/constructor_rewrite
[dbsrgits/DBIx-Class.git] / t / sqlmaker / msaccess.t
1 use strict;
2 use warnings;
3 use Test::More;
4 use lib qw(t/lib);
5 use DBICTest;
6 use DBIC::SqlMakerTest;
7
8 use DBIx::Class::SQLMaker::ACCESS ();
9
10 my $sa = DBIx::Class::SQLMaker::ACCESS->new;
11
12 #  my ($self, $table, $fields, $where, $order, @rest) = @_;
13 my ($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 );
25 is_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         [
39             { artist => "artist" },
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 );
47 is_same_sql_bind(
48   $sql, \@bind,
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'
51 );
52
53 done_testing;