Commit | Line | Data |
f66596f9 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
f66596f9 |
5 | |
c7d50a7d |
6 | BEGIN { |
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 |
12 | use lib qw(t/lib); |
327368bc |
13 | use DBICTest; |
70c28808 |
14 | use DBIx::Class::SQLMaker::OracleJoins; |
c61a0748 |
15 | use DBIC::SqlMakerTest; |
16 | |
c7d50a7d |
17 | my $sa = DBIx::Class::SQLMaker::OracleJoins->new; |
67bdc1ef |
18 | |
19 | # my ($self, $table, $fields, $where, $order, @rest) = @_; |
9b459129 |
20 | my ($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 | ); |
32 | is_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 | ); |
50 | is_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 | ); |
68 | is_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 |
74 | done_testing; |
67bdc1ef |
75 | |