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