X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F100populate.t;h=7b893954f241cc5f103ec85ad14841d9d9deb0d0;hb=9e1b549a32fd3457ff65e8cff959c947e941510c;hp=296227c156911fe3dcc006698a918c07f8b23a78;hpb=54e0bd0660145a1a86bf7cc460336e0ee9c6cbfa;p=dbsrgits%2FDBIx-Class.git diff --git a/t/100populate.t b/t/100populate.t index 296227c..7b89395 100644 --- a/t/100populate.t +++ b/t/100populate.t @@ -5,7 +5,7 @@ use Test::More; use lib qw(t/lib); use DBICTest; -plan tests => 1; +plan tests => 22; # perl -le'my $letter = 'a'; for my $i (4..10000) { $letter++; print "[ $i, \"$letter\" ]," }' > tests.txt @@ -10011,4 +10011,75 @@ $schema->populate('Artist', [ [ 10000, "ntn" ], ]); + +## make sure populate honors fields/orders in list context +## schema order +my @links = $schema->populate('Link', [ +[ qw/id url title/ ], +[ qw/2 burl btitle/ ] +]); +is(scalar @links, 1); + +my $link2 = shift @links; +is($link2->id, 2, 'Link 2 id'); +is($link2->url, 'burl', 'Link 2 url'); +is($link2->title, 'btitle', 'Link 2 title'); + +## non-schema order +@links = $schema->populate('Link', [ +[ qw/id title url/ ], +[ qw/3 ctitle curl/ ] +]); +is(scalar @links, 1); + +my $link3 = shift @links; +is($link3->id, 3, 'Link 3 id'); +is($link3->url, 'curl', 'Link 3 url'); +is($link3->title, 'ctitle', 'Link 3 title'); + +## not all physical columns +@links = $schema->populate('Link', [ +[ qw/id title/ ], +[ qw/4 dtitle/ ] +]); +is(scalar @links, 1); + +my $link4 = shift @links; +is($link4->id, 4, 'Link 4 id'); +is($link4->url, undef, 'Link 4 url'); +is($link4->title, 'dtitle', 'Link 4 title'); + + +## make sure populate -> insert_bulk honors fields/orders in void context +## schema order +$schema->populate('Link', [ +[ qw/id url title/ ], +[ qw/5 eurl etitle/ ] +]); +my $link5 = $schema->resultset('Link')->find(5); +is($link5->id, 5, 'Link 5 id'); +is($link5->url, 'eurl', 'Link 5 url'); +is($link5->title, 'etitle', 'Link 5 title'); + +## non-schema order +$schema->populate('Link', [ +[ qw/id title url/ ], +[ qw/6 ftitle furl/ ] +]); +my $link6 = $schema->resultset('Link')->find(6); +is($link6->id, 6, 'Link 6 id'); +is($link6->url, 'furl', 'Link 6 url'); +is($link6->title, 'ftitle', 'Link 6 title'); + +## not all physical columns +$schema->populate('Link', [ +[ qw/id title/ ], +[ qw/7 gtitle/ ] +]); +my $link7 = $schema->resultset('Link')->find(7); +is($link7->id, 7, 'Link 7 id'); +is($link7->url, undef, 'Link 7 url'); +is($link7->title, 'gtitle', 'Link 7 title'); + + ok(-f "t/var/DBIxClass.db", 'Database created');