X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F41orrible.t;h=660ee40a1a8542607b21ec3305cca553b6ecc60e;hb=c61a0748004eaaeb8207dc8a933ed5213ccce3e6;hp=e8e22df376f61c187b93f1c9a17cdcd947067a59;hpb=eac29141febdcd3fb838c56995c7ac86ee7b010e;p=dbsrgits%2FDBIx-Class.git diff --git a/t/41orrible.t b/t/41orrible.t index e8e22df..660ee40 100644 --- a/t/41orrible.t +++ b/t/41orrible.t @@ -2,11 +2,14 @@ use strict; use warnings; use Test::More; -use DBIx::Class::Storage::DBI; +use DBIx::Class::Storage::DBI::Oracle::WhereJoins; -plan tests => 1; +use lib qw(t/lib); +use DBIC::SqlMakerTest; -my $sa = new DBIC::SQL::Abstract; +plan tests => 4; + +my $sa = new DBIC::SQL::Abstract::Oracle; $sa->limit_dialect('RowNum'); @@ -23,3 +26,63 @@ is($sa->select('rubbish', ) B WHERE r >= 4 ', 'Munged stuff to make Oracle not explode'); + +# test WhereJoins +# search with undefined or empty $cond + +# my ($self, $table, $fields, $where, $order, @rest) = @_; +my ($sql, @bind) = $sa->select( + [ + { me => "cd" }, + [ + { "-join_type" => "LEFT", artist => "artist" }, + { "artist.artistid" => "me.artist" }, + ], + ], + [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ], + undef, + undef +); +is_same_sql_bind( + $sql, \@bind, + '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' +); + +($sql, @bind) = $sa->select( + [ + { me => "cd" }, + [ + { "-join_type" => "", artist => "artist" }, + { "artist.artistid" => "me.artist" }, + ], + ], + [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ], + { 'artist.artistid' => 3 }, + undef +); +is_same_sql_bind( + $sql, \@bind, + '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], + 'WhereJoins search with where clause' +); + +($sql, @bind) = $sa->select( + [ + { me => "cd" }, + [ + { "-join_type" => "LEFT", artist => "artist" }, + { "artist.artistid" => "me.artist" }, + ], + ], + [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ], + [{ 'artist.artistid' => 3 }, { 'me.cdid' => 5 }], + undef +); +is_same_sql_bind( + $sql, \@bind, + '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], + 'WhereJoins search with or in where clause' +); + +