We already depend on latest SQLA - remove all references to >= 1.50 - it will only...
[dbsrgits/DBIx-Class.git] / t / search / subquery.t
index e0f7291..e6bcccf 100644 (file)
@@ -6,12 +6,13 @@ use warnings FATAL => 'all';
 use Data::Dumper;
 
 use Test::More;
+
+plan ( tests => 7 );
+
 use lib qw(t/lib);
 use DBICTest;
 use DBIC::SqlMakerTest;
 
-plan tests => 6;
-
 my $schema = DBICTest->init_schema();
 my $art_rs = $schema->resultset('Artist');
 my $cdrs = $schema->resultset('CD');
@@ -30,16 +31,31 @@ my $cdrs = $schema->resultset('CD');
   );
 }
 
-TODO: {
-  local $TODO = "'+select' doesn't work with as_query yet.";
+{
   my $rs = $art_rs->search(
     {},
     {
-      '+select' => [
+      'select' => [
         $cdrs->search({}, { rows => 1 })->get_column('id')->as_query,
       ],
-      '+as' => [
-        'cdid',
+    },
+  );
+
+  my $arr = $rs->as_query;
+  my ($query, @bind) = @{$$arr};
+  is_same_sql_bind(
+    $query, \@bind,
+    "SELECT (SELECT id FROM cd me LIMIT 1) FROM artist me",
+    [],
+  );
+}
+
+{
+  my $rs = $art_rs->search(
+    {},
+    {
+      '+select' => [
+        $cdrs->search({}, { rows => 1 })->get_column('id')->as_query,
       ],
     },
   );
@@ -48,7 +64,7 @@ TODO: {
   my ($query, @bind) = @{$$arr};
   is_same_sql_bind(
     $query, \@bind,
-    "SELECT me.artistid, me.name, me.rank, me.charfield, (SELECT id FROM cds LIMIT 1) AS cdid FROM artist me",
+    "SELECT me.artistid, me.name, me.rank, me.charfield, (SELECT id FROM cd me LIMIT 1) FROM artist me",
     [],
   );
 }