Merge 'file_column' into 'trunk'
[dbsrgits/DBIx-Class.git] / t / 41orrible.t
CommitLineData
f66596f9 1use strict;
2use warnings;
3
4use Test::More;
67bdc1ef 5#use DBIx::Class::Storage::DBI;
6use DBIx::Class::Storage::DBI::Oracle::WhereJoins;
f66596f9 7
67bdc1ef 8plan tests => 4;
f66596f9 9
67bdc1ef 10my $sa = new DBIC::SQL::Abstract::Oracle;
f66596f9 11
12$sa->limit_dialect('RowNum');
13
14is($sa->select('rubbish',
eac29141 15 [ 'foo.id', 'bar.id', \'TO_CHAR(foo.womble, "blah")' ],
f66596f9 16 undef, undef, 1, 3),
17 'SELECT * FROM
18(
19 SELECT A.*, ROWNUM r FROM
20 (
eac29141 21 SELECT foo.id AS col1, bar.id AS col2, TO_CHAR(foo.womble, "blah") AS col3 FROM rubbish
f66596f9 22 ) A
23 WHERE ROWNUM < 5
24) B
25WHERE r >= 4
26', 'Munged stuff to make Oracle not explode');
67bdc1ef 27
28# test WhereJoins
29# search with undefined or empty $cond
30
31# my ($self, $table, $fields, $where, $order, @rest) = @_;
32is($sa->select([
33 { me => "cd" },
34 [
35 { "-join_type" => "LEFT", artist => "artist" },
36 { "artist.artistid" => "me.artist" },
37 ],
38 ],
39 [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
40 undef,
41 undef),
42 'SELECT cd.cdid, cd.artist, cd.title, cd.year, artist.artistid, artist.name FROM cd me, artist artist WHERE ( artist.artistid(+) = me.artist )', 'WhereJoins search with empty where clause');
43
44is($sa->select([
45 { me => "cd" },
46 [
47 { "-join_type" => "", artist => "artist" },
48 { "artist.artistid" => "me.artist" },
49 ],
50 ],
51 [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
52 { 'artist.artistid' => 3 },
53 undef),
54 '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 = ? ) ) )', 'WhereJoins search with where clause');
55
56is($sa->select([
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 }],
65 undef),
66 '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 = ? ) ) ) ) )', 'WhereJoins search with or in where clause');
67
68