Fix inexplicable 5.8.x C3 errors - roll back e6efde04
[dbsrgits/DBIx-Class.git] / t / sqlmaker / oraclejoin.t
CommitLineData
c0329273 1BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
cb551b07 2use DBIx::Class::Optional::Dependencies -skip_all_without => 'id_shortener';
3
f66596f9 4use strict;
5use warnings;
6
7use Test::More;
f66596f9 8
a5a7bb73 9use DBICTest ':DiffSQL';
70c28808 10use DBIx::Class::SQLMaker::OracleJoins;
c61a0748 11
c7d50a7d 12my $sa = DBIx::Class::SQLMaker::OracleJoins->new;
67bdc1ef 13
f6fff270 14for my $rhs ( "me.artist", { -ident => "me.artist" } ) {
15
67bdc1ef 16# my ($self, $table, $fields, $where, $order, @rest) = @_;
9b459129 17my ($sql, @bind) = $sa->select(
18 [
67bdc1ef 19 { me => "cd" },
20 [
21 { "-join_type" => "LEFT", artist => "artist" },
f6fff270 22 { "artist.artistid" => $rhs },
67bdc1ef 23 ],
24 ],
25 [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
26 undef,
9b459129 27 undef
28);
29is_same_sql_bind(
30 $sql, \@bind,
31 'SELECT cd.cdid, cd.artist, cd.title, cd.year, artist.artistid, artist.name FROM cd me, artist artist WHERE ( artist.artistid(+) = me.artist )', [],
32 'WhereJoins search with empty where clause'
33);
67bdc1ef 34
9b459129 35($sql, @bind) = $sa->select(
36 [
67bdc1ef 37 { me => "cd" },
38 [
39 { "-join_type" => "", artist => "artist" },
f6fff270 40 { "artist.artistid" => $rhs },
67bdc1ef 41 ],
42 ],
43 [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
44 { 'artist.artistid' => 3 },
9b459129 45 undef
46);
47is_same_sql_bind(
48 $sql, \@bind,
49 '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],
50 'WhereJoins search with where clause'
51);
67bdc1ef 52
9b459129 53($sql, @bind) = $sa->select(
54 [
67bdc1ef 55 { me => "cd" },
56 [
f6fff270 57 { "-join_type" => "right", artist => "artist" },
58 { "artist.artistid" => $rhs },
59 ],
60 ],
61 [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
62 { 'artist.artistid' => 3 },
63 undef
64);
65is_same_sql_bind(
66 $sql, \@bind,
67 '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],
68 'WhereJoins search with where clause'
69);
70
71($sql, @bind) = $sa->select(
72 [
73 { me => "cd" },
74 [
67bdc1ef 75 { "-join_type" => "LEFT", artist => "artist" },
f6fff270 76 { "artist.artistid" => $rhs },
67bdc1ef 77 ],
78 ],
79 [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
80 [{ 'artist.artistid' => 3 }, { 'me.cdid' => 5 }],
9b459129 81 undef
82);
83is_same_sql_bind(
84 $sql, \@bind,
85 '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],
86 'WhereJoins search with or in where clause'
87);
67bdc1ef 88
f6fff270 89}
90
327368bc 91done_testing;
67bdc1ef 92