use warnings;
use Test::More;
+use Test::Warn;
use lib qw(t/lib);
use DBICTest;
SCHEMA_POPULATE1: {
- ## Test to make sure that the old $schema->populate is using the new method
- ## for $resultset->populate when in void context and with sub objects.
+ # throw a monkey wrench
+ my $post_jnap_monkeywrench = $schema->resultset('Artist')->find(1)->update({ name => undef });
- $schema->populate('Artist', [
+ warnings_exist { $schema->populate('Artist', [
[qw/name cds/],
["001First Artist", [
[undef, [
{title=>"004Title1", year=>2010}
]],
- ]);
+ ]) } qr/\QFast-path populate() of non-uniquely identifiable rows with related data is not possible/;
isa_ok $schema, 'DBIx::Class::Schema';
- my ($undef, $artist1, $artist2, $artist3 ) = $schema->resultset('Artist')->search({
+ my ( $preexisting_undef, $artist1, $artist2, $artist3, $undef ) = $schema->resultset('Artist')->search({
name=>["001First Artist","002Second Artist","003Third Artist", undef]},
- {order_by=>'name ASC'})->all;
+ {order_by => { -asc => 'artistid' }})->all;
isa_ok $artist1, 'DBICTest::Artist';
isa_ok $artist2, 'DBICTest::Artist';
ok $artist3->cds->count eq 1, "Got Right number of CDs for Artist3";
ok $undef->cds->count eq 1, "Got Right number of CDs for Artist4";
+ $post_jnap_monkeywrench->delete;
+
ARTIST1CDS: {
my ($cd1, $cd2, $cd3) = $artist1->cds->search(undef, {order_by=>'year ASC'});
},
];
- $cd_rs->populate($cds);
+ warnings_exist {
+ $cd_rs->populate($cds)
+ } qr/\QFast-path populate() of belongs_to relationship data is not possible/;
my ($cdA, $cdB) = $cd_rs->search(
{title=>[sort map {$_->{title}} @$cds]},
},
];
- $cd_rs->populate($cds);
+ warnings_exist {
+ $cd_rs->populate($cds);
+ } qr/\QFast-path populate() of belongs_to relationship data is not possible/;
my ($cdA, $cdB, $cdC) = $cd_rs->search(
{title=>[sort map {$_->{title}} @$cds]},