+use DBIx::Class::Optional::Dependencies -skip_all_without => 'id_shortener';
+
use strict;
use warnings;
use Test::More;
use lib qw(t/lib);
+use DBICTest ':DiffSQL';
use DBIx::Class::SQLMaker::OracleJoins;
-use DBICTest;
-use DBIC::SqlMakerTest;
-my $sa = new DBIx::Class::SQLMaker::OracleJoins;
+my $sa = DBIx::Class::SQLMaker::OracleJoins->new;
-# search with undefined or empty $cond
+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' ],
{ 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' ],
[
{ 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' ],
'WhereJoins search with or in where clause'
);
+}
+
done_testing;