Rename SQLAHacks to SQLMaker, shuffle around files, add extensive
[dbsrgits/DBIx-Class.git] / t / sqlmaker / oraclejoin.t
CommitLineData
f66596f9 1use strict;
2use warnings;
3
4use Test::More;
f66596f9 5
c61a0748 6use lib qw(t/lib);
d5dedbd6 7use DBIx::Class::SQLMaker::OracleJoins;
327368bc 8use DBICTest;
c61a0748 9use DBIC::SqlMakerTest;
10
d5dedbd6 11my $sa = new DBIx::Class::SQLMaker::OracleJoins;
f66596f9 12
67bdc1ef 13# search with undefined or empty $cond
14
15# my ($self, $table, $fields, $where, $order, @rest) = @_;
9b459129 16my ($sql, @bind) = $sa->select(
17 [
67bdc1ef 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,
9b459129 26 undef
27);
28is_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);
67bdc1ef 33
9b459129 34($sql, @bind) = $sa->select(
35 [
67bdc1ef 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 },
9b459129 44 undef
45);
46is_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);
67bdc1ef 51
9b459129 52($sql, @bind) = $sa->select(
53 [
67bdc1ef 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 }],
9b459129 62 undef
63);
64is_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);
67bdc1ef 69
327368bc 70done_testing;
67bdc1ef 71