account for coderefs partially
[dbsrgits/DBIx-Class.git] / t / 100populate.t
index 94a9737..d0427f1 100644 (file)
@@ -445,19 +445,37 @@ lives_ok ( sub {
   ])
 }, 'empty has_many relationship accepted by populate');
 
-done_testing;
+lives_ok ( sub {
+  my $genre_max = $schema->resultset('Genre')->get_column('genreid')->max;
+  $schema->populate('CD', [
+    {cdid => 10002, artist => $artist->id, title => 'Pretty Much Foo', year => 2011, genre => { name => 'country' } }
+  ]);
+
+  is_deeply($schema->resultset('Genre')->search({ name => 'country' })->all_hri,
+    [{ genreid => $genre_max + 1, name => 'country' }],
+    "Populate() belongs_to inserts in void context"
+  );
+}, 'void context belongs_to rels are populated');
+
+#my $q = $schema->resultset('CD')->search({}, { columns => [qw/artist year/], group_by => 'artist' })->as_query;
+#$schema->storage->insert_bulk($artist_src, [qw/name rank/], [[[qw/foo 1/], [qw/baz 2/]],  $q, [[qw/asdf 5/], [qw/uhiuh 6/]]]);
+#my @cols = $artist_src->columns;
 
 my $artist_rs = $schema->resultset('Artist');
 my $artist_src = $artist_rs->result_source;
 
-my $q = $schema->resultset('CD')->search({}, { columns => [qw/artist year/], group_by => 'artist' })->as_query;
+#use DDP::S; scope {
 my $count = 0;
 my $name = "zaaaaa";
+$artist_rs->populate([
+  [qw/artistid name/],
+  [109, 'some crap'],
+  [110, 'some crap'],
+  sub {
+    return [$name++, ++$count] unless $count > 5;
+    return undef;
+  },
+]);
+#};
 
-#$schema->storage->insert_bulk($artist_src, [qw/name rank/], [[[qw/foo 1/], [qw/baz 2/]], sub {
-#  return [$name++, ++$count] unless $count > 5;
-#  return undef;
-#}, $q, [[qw/asdf 5/], [qw/uhiuh 6/]]]);
-
-my @cols = $artist_src->columns;
-$rs->populate(\@cols, $rs->search(undef)->as_query )
+done_testing;