Tighten up select list processing in ::SQLMaker
[dbsrgits/DBIx-Class.git] / t / sqlmaker / core_quoted.t
index e90befe..8682093 100644 (file)
@@ -1,9 +1,11 @@
+BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
+
 use strict;
 use warnings;
 
 use Test::More;
+use Test::Warn;
 
-use lib qw(t/lib);
 use DBICTest ':DiffSQL';
 
 my $schema = DBICTest->init_schema();
@@ -24,7 +26,7 @@ my ($sql, @bind) = $sql_maker->select(
                 '-join_type' => ''
               },
               {
-                'artist.artistid' => 'me.artist'
+                'artist.artistid' => { -ident => 'me.artist' },
               }
             ],
             [
@@ -33,7 +35,7 @@ my ($sql, @bind) = $sql_maker->select(
                 '-join_type' => 'left'
               },
               {
-                'tracks.cd' => 'me.cdid'
+                'tracks.cd' => { -ident => 'me.cdid' },
               }
             ],
           ],
@@ -307,7 +309,7 @@ $sql_maker->quote_char([qw/[ ]/]);
                 '-join_type' => ''
               },
               {
-                'artist.artistid' => 'me.artist'
+                'artist.artistid' => { -ident => 'me.artist' }
               }
             ]
           ],
@@ -352,4 +354,15 @@ is_same_sql_bind(
   'bracket quoted table names for UPDATE'
 );
 
+
+# Warning and sane behavior on ... select => [] ...
+warnings_exist {
+  local $TODO = "Some day we need to stop issuing implicit SELECT *";
+  is_same_sql_bind(
+    $schema->resultset("Artist")->search({}, { columns => [] })->as_query,
+    '( SELECT 42 FROM [artist] [me] )',
+    [],
+  );
+} qr/\QResultSets with an empty selection are deprecated (you almost certainly did not mean to do that): if this is indeed your intent you must explicitly supply/;
+
 done_testing;