Christopher H. Laco wrote:
> Christopher H. Laco wrote:
> [snip]
> 
> I've committed failing tests to 100populate.t. These test pass under
> trunk, and on current prior to changeset 2793:
> 
> To summarize, under trunk, populate honors the field orders given, and
> allows one to only populate some fields out of the entire schema. This
> is useful if the data being populate is coming from an outside source
> that has no knowledge of the db column order, or the entire set of columns.
> 
>> ## make sure populate -> insert_bulk honors fields/orders
>> ## schema order
>> $schema->populate('Link', [
>> [ qw/id url title/ ],
>> [ qw/2 burl btitle/ ]
>> ]);
>> my $link2 = $schema->resultset('Link')->find(2);
>> is($link2->id, 2, 'Link 2 id');
>> is($link2->url, 'burl', 'Link 2 url');
>> is($link2->title, 'btitle', 'Link 2 title');
>>
>> ## non-schema order
>> $schema->populate('Link', [
>> [ qw/id title url/ ],
>> [ qw/3 ctitle curl/ ]
>> ]);
>> my $link3 = $schema->resultset('Link')->find(3);
>> 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
>> $schema->populate('Link', [
>> [ qw/id title/ ],
>> [ qw/4 dtitle/ ]
>> ]);
>> my $link4 = $schema->resultset('Link')->find(4);
>> is($link4->id, 4, 'Link 4 id');
>> is($link4->url, undef, 'Link 4 url');
>> is($link4->title, 'dtitle', 'Link 4 title');
> 
> Under the latest current, that last two groups of tests fail. Column
> order is ignored, and one must populate by specifying all of the
> columns, no just some of them.
> 
> This problem only happens in a void context because insert_bulk in
> Storage::DBI does nothing with $cols passed into it in things like:
> 
>> my ($sql, @bind) = $self->sql_maker->insert($table, @$data);
> 
> In list context, populate create real objects that take care of the
> columns, orders, and the ability to not specify all of them.
> 
> Game on.
> -=Chris
> 

No really, this time I mean it. Anything worth testing is worth testing
verbosely.

I've updated the tests to test populate in list context, vs void context.

-=Chris

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to