Drop-in legacy code for DB2-AS/400
[dbsrgits/DBIx-Class.git] / t / sqlmaker / oraclejoin.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5
6 use lib qw(t/lib);
7 use DBIx::Class::SQLMaker::OracleJoins;
8 use DBICTest;
9 use DBIC::SqlMakerTest;
10
11 my $sa = new DBIx::Class::SQLMaker::OracleJoins;
12
13 # search with undefined or empty $cond
14
15 #  my ($self, $table, $fields, $where, $order, @rest) = @_;
16 my ($sql, @bind) = $sa->select(
17     [
18         { me => "cd" },
19         [
20             { "-join_type" => "LEFT", artist => "artist" },
21             { "artist.artistid" => "me.artist" },
22         ],
23     ],
24     [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
25     undef,
26     undef
27 );
28 is_same_sql_bind(
29   $sql, \@bind,
30   'SELECT cd.cdid, cd.artist, cd.title, cd.year, artist.artistid, artist.name FROM cd me, artist artist WHERE ( artist.artistid(+) = me.artist )', [],
31   'WhereJoins search with empty where clause'
32 );
33
34 ($sql, @bind) = $sa->select(
35     [
36         { me => "cd" },
37         [
38             { "-join_type" => "", artist => "artist" },
39             { "artist.artistid" => "me.artist" },
40         ],
41     ],
42     [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
43     { 'artist.artistid' => 3 },
44     undef
45 );
46 is_same_sql_bind(
47   $sql, \@bind,
48   'SELECT cd.cdid, cd.artist, cd.title, cd.year, artist.artistid, artist.name FROM cd me, artist artist WHERE ( ( ( artist.artistid = me.artist ) AND ( artist.artistid = ? ) ) )', [3],
49   'WhereJoins search with where clause'
50 );
51
52 ($sql, @bind) = $sa->select(
53     [
54         { me => "cd" },
55         [
56             { "-join_type" => "LEFT", artist => "artist" },
57             { "artist.artistid" => "me.artist" },
58         ],
59     ],
60     [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
61     [{ 'artist.artistid' => 3 }, { 'me.cdid' => 5 }],
62     undef
63 );
64 is_same_sql_bind(
65   $sql, \@bind,
66   'SELECT cd.cdid, cd.artist, cd.title, cd.year, artist.artistid, artist.name FROM cd me, artist artist WHERE ( ( ( artist.artistid(+) = me.artist ) AND ( ( ( artist.artistid = ? ) OR ( me.cdid = ? ) ) ) ) )', [3, 5],
67   'WhereJoins search with or in where clause'
68 );
69
70 done_testing;
71