Now SQLA 1.50 compatible - no changes to tests, no additions. Just compat
[dbsrgits/DBIx-Class.git] / t / 41orrible.t
CommitLineData
f66596f9 1use strict;
2use warnings;
3
4use Test::More;
67bdc1ef 5use DBIx::Class::Storage::DBI::Oracle::WhereJoins;
f66596f9 6
cadd7ab8 7use lib qw(t/lib);
8use DBIC::SqlMakerTest;
9
67bdc1ef 10plan tests => 4;
f66596f9 11
67bdc1ef 12my $sa = new DBIC::SQL::Abstract::Oracle;
f66596f9 13
14$sa->limit_dialect('RowNum');
15
cadd7ab8 16ok (eq_sql
17 (
18 $sa->select (
19 'rubbish',
20 [ 'foo.id', 'bar.id', \'TO_CHAR(foo.womble, "blah")' ],
21 undef, undef, 1, 3
22 ),
23 q/SELECT * FROM
24 (
25 SELECT A.*, ROWNUM r FROM
26 (
27 SELECT foo.id AS col1, bar.id AS col2, TO_CHAR(foo.womble, "blah") AS col3 FROM rubbish
28 ) A
29 WHERE ROWNUM < 5
30 ) B
31 WHERE r >= 4
32 /,
33 ),
34 'Munged stuff to make Oracle not explode'
35);
67bdc1ef 36
37# test WhereJoins
38# search with undefined or empty $cond
39
40# my ($self, $table, $fields, $where, $order, @rest) = @_;
cadd7ab8 41my ($sql, @bind) = $sa->select(
42 [
67bdc1ef 43 { me => "cd" },
44 [
45 { "-join_type" => "LEFT", artist => "artist" },
46 { "artist.artistid" => "me.artist" },
47 ],
48 ],
49 [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
50 undef,
cadd7ab8 51 undef
52);
53
54is_same_sql_bind (
55 $sql, \@bind,
56 'SELECT cd.cdid, cd.artist, cd.title, cd.year, artist.artistid, artist.name FROM cd me, artist artist WHERE ( artist.artistid(+) = me.artist )',
57 [],
58 'WhereJoins search with empty where clause',
59);
67bdc1ef 60
cadd7ab8 61($sql, @bind) = $sa->select(
62 [
67bdc1ef 63 { me => "cd" },
64 [
65 { "-join_type" => "", artist => "artist" },
66 { "artist.artistid" => "me.artist" },
67 ],
68 ],
69 [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
70 { 'artist.artistid' => 3 },
cadd7ab8 71 undef
72);
67bdc1ef 73
cadd7ab8 74is_same_sql_bind (
75 $sql, \@bind,
76 '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 = ? ) ) )',
77 [ 3 ],
78 'WhereJoins search with where clause'
79);
80
81($sql, @bind) = $sa->select(
82 [
67bdc1ef 83 { me => "cd" },
84 [
85 { "-join_type" => "LEFT", artist => "artist" },
86 { "artist.artistid" => "me.artist" },
87 ],
88 ],
89 [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
90 [{ 'artist.artistid' => 3 }, { 'me.cdid' => 5 }],
cadd7ab8 91 undef
92);
67bdc1ef 93
cadd7ab8 94is_same_sql_bind (
95 $sql, \@bind,
96 '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 = ? ) ) ) ) )',
97 [ 3, 5 ],
98 'WhereJoins search with or in where clause'
99);