11 my $schema = DBICTest->init_schema();
13 # The map below generates stuff like:
14 # [ qw/artistid name/ ],
21 my $start_id = 'populateXaaaaaa';
25 $schema->populate('Artist', [ [ qw/artistid name/ ], map { [ ($_ + $offset) => $start_id++ ] } ( 1 .. $rows ) ] );
27 $schema->resultset ('Artist')->search ({ name => { -like => 'populateX%' } })->count,
29 'populate created correct number of rows with massive AoA bulk insert',
32 my $artist = $schema->resultset ('Artist')
33 ->search ({ 'cds.title' => { '!=', undef } }, { join => 'cds' })
35 my $ex_title = $artist->cds->first->title;
39 $schema->populate('CD', [
42 cdid => $i++, # without a PK the bulk insert does not engage - how come?
43 artist => $artist->id,
47 } ('Huey', 'Dewey', $ex_title, 'Louie')
49 }, qr/columns .+ are not unique for populate slice.+$ex_title/ms, 'Readable exception thrown for failed populate');
51 ## make sure populate honors fields/orders in list context
53 my @links = $schema->populate('Link', [
59 my $link2 = shift @links;
60 is($link2->id, 2, 'Link 2 id');
61 is($link2->url, 'burl', 'Link 2 url');
62 is($link2->title, 'btitle', 'Link 2 title');
65 @links = $schema->populate('Link', [
71 my $link3 = shift @links;
72 is($link3->id, 3, 'Link 3 id');
73 is($link3->url, 'curl', 'Link 3 url');
74 is($link3->title, 'ctitle', 'Link 3 title');
76 ## not all physical columns
77 @links = $schema->populate('Link', [
83 my $link4 = shift @links;
84 is($link4->id, 4, 'Link 4 id');
85 is($link4->url, undef, 'Link 4 url');
86 is($link4->title, 'dtitle', 'Link 4 title');
89 ## make sure populate -> insert_bulk honors fields/orders in void context
91 $schema->populate('Link', [
95 my $link5 = $schema->resultset('Link')->find(5);
96 is($link5->id, 5, 'Link 5 id');
97 is($link5->url, 'eurl', 'Link 5 url');
98 is($link5->title, 'etitle', 'Link 5 title');
101 $schema->populate('Link', [
102 [ qw/id title url/ ],
103 [ qw/6 ftitle furl/ ]
105 my $link6 = $schema->resultset('Link')->find(6);
106 is($link6->id, 6, 'Link 6 id');
107 is($link6->url, 'furl', 'Link 6 url');
108 is($link6->title, 'ftitle', 'Link 6 title');
110 ## not all physical columns
111 $schema->populate('Link', [
115 my $link7 = $schema->resultset('Link')->find(7);
116 is($link7->id, 7, 'Link 7 id');
117 is($link7->url, undef, 'Link 7 url');
118 is($link7->title, 'gtitle', 'Link 7 title');