Merge branch 'master' into topic/constructor_rewrite
[dbsrgits/DBIx-Class.git] / t / prefetch / incomplete.t
index 000a386..36f259f 100644 (file)
@@ -1,13 +1,11 @@
 use strict;
-use warnings;  
+use warnings;
 
 use Test::More;
 use Test::Exception;
 use lib qw(t/lib);
 use DBICTest;
 
-plan tests => 9;
-
 my $schema = DBICTest->init_schema();
 
 lives_ok(sub {
@@ -102,3 +100,14 @@ lives_ok(sub {
   is ($cd->artist->name, 'Random Boy Band', 'Artist object has correct name');
 
 }, 'implicit keyless prefetch works');
+
+# sane error
+throws_ok(
+  sub {
+    $schema->resultset('Track')->search({}, { join => { cd => 'artist' }, '+columns' => 'artist.name' } )->next;
+  },
+  qr|\QCan't inflate manual prefetch into non-existent relationship 'artist' from 'Track', check the inflation specification (columns/as) ending in 'artist.name'|,
+  'Sensible error message on mis-specified "as"',
+);
+
+done_testing;