new config option to DBICTest to let you set an alternative storage type, start on...
[dbsrgits/DBIx-Class.git] / t / 41orrible.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 #use DBIx::Class::Storage::DBI;
6 use DBIx::Class::Storage::DBI::Oracle::WhereJoins;
7
8 plan tests => 4;
9
10 my $sa = new DBIC::SQL::Abstract::Oracle;
11
12 $sa->limit_dialect('RowNum');
13
14 is($sa->select('rubbish',
15                   [ 'foo.id', 'bar.id', \'TO_CHAR(foo.womble, "blah")' ],
16                   undef, undef, 1, 3),
17    'SELECT * FROM
18 (
19     SELECT A.*, ROWNUM r FROM
20     (
21         SELECT foo.id AS col1, bar.id AS col2, TO_CHAR(foo.womble, "blah") AS col3 FROM rubbish 
22     ) A
23     WHERE ROWNUM < 5
24 ) B
25 WHERE r >= 4
26 ', 'Munged stuff to make Oracle not explode');
27
28 # test WhereJoins
29 # search with undefined or empty $cond
30
31 #  my ($self, $table, $fields, $where, $order, @rest) = @_;
32 is($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
44 is($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
56 is($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