Cherry picks from current/for_cpan_index (flux due to not-yet-clear-policy)
[dbsrgits/DBIx-Class.git] / t / sqlmaker / oraclejoin.t
index c1725e0..e8e7444 100644 (file)
@@ -15,13 +15,15 @@ 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 +41,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 +58,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 +90,7 @@ is_same_sql_bind(
   'WhereJoins search with or in where clause'
 );
 
+}
+
 done_testing;