Factor out bindattr resolver and tighten code a bit
[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);
327368bc 13use DBICTest;
70c28808 14use DBIx::Class::SQLMaker::OracleJoins;
c61a0748 15use DBIC::SqlMakerTest;
16
c7d50a7d 17my $sa = DBIx::Class::SQLMaker::OracleJoins->new;
67bdc1ef 18
19# my ($self, $table, $fields, $where, $order, @rest) = @_;
9b459129 20my ($sql, @bind) = $sa->select(
21 [
67bdc1ef 22 { me => "cd" },
23 [
24 { "-join_type" => "LEFT", artist => "artist" },
25 { "artist.artistid" => "me.artist" },
26 ],
27 ],
28 [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
29 undef,
9b459129 30 undef
31);
32is_same_sql_bind(
33 $sql, \@bind,
34 'SELECT cd.cdid, cd.artist, cd.title, cd.year, artist.artistid, artist.name FROM cd me, artist artist WHERE ( artist.artistid(+) = me.artist )', [],
35 'WhereJoins search with empty where clause'
36);
67bdc1ef 37
9b459129 38($sql, @bind) = $sa->select(
39 [
67bdc1ef 40 { me => "cd" },
41 [
42 { "-join_type" => "", artist => "artist" },
43 { "artist.artistid" => "me.artist" },
44 ],
45 ],
46 [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
47 { 'artist.artistid' => 3 },
9b459129 48 undef
49);
50is_same_sql_bind(
51 $sql, \@bind,
52 '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],
53 'WhereJoins search with where clause'
54);
67bdc1ef 55
9b459129 56($sql, @bind) = $sa->select(
57 [
67bdc1ef 58 { me => "cd" },
59 [
60 { "-join_type" => "LEFT", artist => "artist" },
61 { "artist.artistid" => "me.artist" },
62 ],
63 ],
64 [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
65 [{ 'artist.artistid' => 3 }, { 'me.cdid' => 5 }],
9b459129 66 undef
67);
68is_same_sql_bind(
69 $sql, \@bind,
70 '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],
71 'WhereJoins search with or in where clause'
72);
67bdc1ef 73
327368bc 74done_testing;
67bdc1ef 75