Add import-time-skip support to OptDeps, switch most tests over to that
[dbsrgits/DBIx-Class.git] / t / sqlmaker / oraclejoin.t
index 3ba82ab..11298b0 100644 (file)
@@ -1,28 +1,25 @@
+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;
+use DBICTest ':DiffSQL';
 use DBIx::Class::SQLMaker::OracleJoins;
-use DBIC::SqlMakerTest;
 
 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' ],
@@ -40,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' ],
@@ -57,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' ],
@@ -71,5 +86,7 @@ is_same_sql_bind(
   'WhereJoins search with or in where clause'
 );
 
+}
+
 done_testing;