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