On 02/03/2018 05:05 PM, Roman Daniel wrote:
__PACKAGE__->has_one(
'address',
'MyApp::Schema::Result::Address',
{ 'foreign.address_id' => 'self.address_id' }
);
The correct relationship here is `might_have`, this is what confuses the
entire multi-creation chain. Please read this comment ( not the whole
thread ) for more info:
https://rt.cpan.org/Ticket/Display.html?id=83712#txn-1187773
$schema->resultset('Customer')->create(
{
name => $_,
address => {
street => 'Axmanova 11',
city => 'Brno',
}
}
)
rabbit@Ahasver:~/devel/dbic$ grep -C2 liner_notes
t/lib/DBICTest/Schema/CD.pm
# tests oddball legacy syntax
__PACKAGE__->might_have(
liner_notes => 'DBICTest::Schema::LinerNotes', undef,
{ proxy => [ qw/notes/ ] },
);
rabbit@Ahasver:~/devel/dbic$ perl -It/lib -Ilib -MDBICTest -e '
my $s = DBICTest->init_schema;
$s->storage->debug(1);
$s->resultset("CD")->create({
title => "foo",
year => 2000,
artist => 1,
liner_notes => { notes => "foo" }
})
'
BEGIN WORK
INSERT INTO cd ( artist, title, year) VALUES ( ?, ?, ? ): '1', 'foo', '2000'
INSERT INTO liner_notes ( liner_id, notes) VALUES ( ?, ? ): '6', 'foo'
COMMIT
Cheers!
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]