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