squash, fixes subquery with insert_bulk
[dbsrgits/DBIx-Class.git] / t / 100populate.t
index b6ea7d9..0310de5 100644 (file)
@@ -6,6 +6,7 @@ use Test::Exception;
 use Test::Warn;
 use lib qw(t/lib);
 use DBICTest;
+use DBIx::Class::_Util 'sigwarn_silencer';
 use Path::Class::File ();
 use Math::BigInt;
 use List::Util qw/shuffle/;
@@ -22,7 +23,7 @@ my $schema = DBICTest->init_schema();
 #   [ 10000, "ntn" ],
 
 my $start_id = 'populateXaaaaaa';
-my $rows = 10_000;
+my $rows = 10;
 my $offset = 3;
 
 $schema->populate('Artist', [ [ qw/artistid name/ ], map { [ ($_ + $offset) => $start_id++ ] } shuffle ( 1 .. $rows ) ] );
@@ -209,6 +210,11 @@ is($link7->title, 'gtitle', 'Link 7 title');
 my $rs = $schema->resultset('Artist');
 $rs->delete;
 throws_ok {
+    # this warning is correct, but we are not testing it here
+    # what we are after is the correct exception when an int
+    # fails to coerce into a sqlite rownum
+    local $SIG{__WARN__} = sigwarn_silencer( qr/datatype mismatch.+ foo as integer/ );
+
     $rs->populate([
         {
             artistid => 1,
@@ -223,7 +229,7 @@ throws_ok {
             name => 'foo3',
         },
     ]);
-} qr/\Qexecute_for_fetch() aborted with 'datatype mismatch\E\b/, 'bad slice';
+} qr/\Qexecute_for_fetch() aborted with 'datatype mismatch\E\b/, 'bad slice fails PK insert';
 
 is($rs->count, 0, 'populate is atomic');
 
@@ -312,6 +318,8 @@ lives_ok {
 
 # test all kinds of population with stringified objects
 warnings_like {
+  local $ENV{DBIC_RT79576_NOWARN};
+
   my $rs = $schema->resultset('Artist')->search({}, { columns => [qw(name rank)], order_by => 'artistid' });
 
   # the stringification has nothing to do with the artist name
@@ -438,3 +446,17 @@ lives_ok ( sub {
 }, 'empty has_many relationship accepted by populate');
 
 done_testing;
+
+use DDP; use Data::Dumper;
+my $q = $schema->resultset('Artist')
+               ->search({
+                },
+                {
+                  columns => [qw/name rank/]
+                })->as_query;
+              use DDP; p $q;
+#p $q;
+#diag Dumper($q);
+#p $schema->resultset('Artist')->result_source;
+#p Dumper $q;
+$schema->storage->insert_bulk($schema->resultset('Artist')->result_source, [qw/name rank/], $q);