X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fsqlmaker%2Foraclejoin.t;h=de49bbfbb3c243d863670f521c3a7fb5ccb2a381;hb=555df627fa78458a6d0338ef90059139e952f8c1;hp=c1725e053fdaa543248382f8ee868a21465fb030;hpb=a5a7bb733a940db710b7408508374833683a2e79;p=dbsrgits%2FDBIx-Class.git diff --git a/t/sqlmaker/oraclejoin.t b/t/sqlmaker/oraclejoin.t index c1725e0..de49bbf 100644 --- a/t/sqlmaker/oraclejoin.t +++ b/t/sqlmaker/oraclejoin.t @@ -1,27 +1,25 @@ +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } +use DBIx::Class::Optional::Dependencies -skip_all_without => 'id_shortener'; + use strict; use warnings; use Test::More; -BEGIN { - require DBIx::Class::Optional::Dependencies; - plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('id_shortener') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('id_shortener'); -} - -use lib qw(t/lib); use DBICTest ':DiffSQL'; use DBIx::Class::SQLMaker::OracleJoins; my $sa = DBIx::Class::SQLMaker::OracleJoins->new; +for my $rhs ( "me.artist", { -ident => "me.artist" } ) { + # my ($self, $table, $fields, $where, $order, @rest) = @_; my ($sql, @bind) = $sa->select( [ { me => "cd" }, [ { "-join_type" => "LEFT", artist => "artist" }, - { "artist.artistid" => "me.artist" }, + { "artist.artistid" => $rhs }, ], ], [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ], @@ -39,7 +37,7 @@ is_same_sql_bind( { me => "cd" }, [ { "-join_type" => "", artist => "artist" }, - { "artist.artistid" => "me.artist" }, + { "artist.artistid" => $rhs }, ], ], [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ], @@ -56,8 +54,26 @@ is_same_sql_bind( [ { me => "cd" }, [ + { "-join_type" => "right", artist => "artist" }, + { "artist.artistid" => $rhs }, + ], + ], + [ '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" }, + { "artist.artistid" => $rhs }, ], ], [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ], @@ -70,5 +86,7 @@ is_same_sql_bind( 'WhereJoins search with or in where clause' ); +} + done_testing;