8 my $schema = DBICTest->init_schema();
12 my $label = $schema->resultset('Label')->find({ labelid => 1 });
14 # Check that you can leave off the alias
16 my $existing_agent = $label->agents->find_or_create({
19 ok(! $existing_agent->is_changed, 'find_or_create on prefetched has_many with same column names: row is clean');
20 is($existing_agent->name, 'Ted', 'find_or_create on prefetched has_many with same column names: name matches existing entry');
22 my $new_agent = $label->agents->find_or_create({
23 name => 'Someone Else',
25 ok(! $new_agent->is_changed, 'find_or_create on prefetched has_many with same column names: row is clean');
26 is($new_agent->name, 'Someone Else', 'find_or_create on prefetched has_many with same column names: name matches');
29 # Check that you can specify the alias
31 my $existing_agent = $label->agents->find_or_create({
32 'me.name' => 'Someone Else',
34 ok(! $existing_agent->is_changed, 'find_or_create on prefetched has_many with same column names: row is clean');
35 is($existing_agent->name, 'Someone Else', 'find_or_create on prefetched has_many with same column names: can be disambiguated with "me." for existing entry');
37 my $new_agent = $label->agents->find_or_create({
38 'me.name' => 'Some New Guy',
40 ok(! $new_agent->is_changed, 'find_or_create on prefetched has_many with same column names: row is clean');
41 is($new_agent->name, 'Some New Guy', 'find_or_create on prefetched has_many with same column names: can be disambiguated with "me." for new entry');