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