<div dir="ltr"><div>Thanks for your reply, but it does not work. Using might_have insted of has_one makes no difference, the related record is still searched for. Output of my script with DBIC_MULTICREATE_DEBUG.</div><div><br></div><div>MC MyApp::Schema::Result::Customer=HASH(0x2b23678) constructing address via find_or_new</div><div>MC MyApp::Schema::Result::Customer=HASH(0x2b23678) inserting (name, Pavel Petr, address_id, 2)</div><div>MC MyApp::Schema::Result::Customer=HASH(0x3098208) constructing address via find_or_new</div><div>MC MyApp::Schema::Result::Customer=HASH(0x3098208) inserting (address_id, 2, name, Petr Pavel)</div><div><br></div><div>Also your example with CD and liner_notes is very different from mine. Your related table liner_notes contains foreign key to your primary table CD, while my related table address contains no reference to customer table. It is the intention, because there may be more entities (customer, business_owner, ...) storing their addresses in address table.</div><div><br></div><div>All I wanted from multi-creation was to create related record first without any attempt to find it before (and reuse its id). The more I look into DBIC code, the more it seems to me that is impossible to define relationships that way and I will need to create the related object first manually. Am I correct?</div><div><br></div><div>Roman</div><div><br></div><div>(I use DBIC 0.082841)</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-02-04 10:19 GMT+01:00 Peter Rabbitson <span dir="ltr">&lt;<a href="mailto:rabbit+dbic@rabbit.us" target="_blank">rabbit+dbic@rabbit.us</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 02/03/2018 05:05 PM, Roman Daniel wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
     __PACKAGE__-&gt;has_one(<br>
         &#39;address&#39;,<br>
         &#39;MyApp::Schema::Result::Addres<wbr>s&#39;,<br>
         { &#39;foreign.address_id&#39; =&gt; &#39;self.address_id&#39; }<br>
     );<br>
<br>
</blockquote>
<br></span>
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: <a href="https://rt.cpan.org/Ticket/Display.html?id=83712#txn-1187773" rel="noreferrer" target="_blank">https://rt.cpan.org/Ticket/Dis<wbr>play.html?id=83712#txn-1187773</a><span class=""><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
     $schema-&gt;resultset(&#39;Customer&#39;)<wbr>-&gt;create(<br>
         {<br>
             name    =&gt; $_,<br>
             address =&gt; {<br>
                 street =&gt; &#39;Axmanova 11&#39;,<br>
                 city   =&gt; &#39;Brno&#39;,<br>
             }<br>
         }<br>
       )<br>
</blockquote>
<br></span>
rabbit@Ahasver:~/devel/dbic$ grep -C2 liner_notes t/lib/DBICTest/Schema/CD.pm<br>
# tests oddball legacy syntax<br>
__PACKAGE__-&gt;might_have(<br>
    liner_notes =&gt; &#39;DBICTest::Schema::LinerNotes&#39;<wbr>, undef,<br>
    { proxy =&gt; [ qw/notes/ ] },<br>
);<br>
<br>
rabbit@Ahasver:~/devel/dbic$ perl -It/lib -Ilib -MDBICTest -e &#39;<br>
  my $s = DBICTest-&gt;init_schema;<br>
  $s-&gt;storage-&gt;debug(1);<br>
  $s-&gt;resultset(&quot;CD&quot;)-&gt;create({<br>
    title =&gt; &quot;foo&quot;,<br>
    year =&gt; 2000,<br>
    artist =&gt; 1,<br>
    liner_notes =&gt; { notes =&gt; &quot;foo&quot; }<br>
  })<br>
&#39;<br>
BEGIN WORK<br>
INSERT INTO cd ( artist, title, year) VALUES ( ?, ?, ? ): &#39;1&#39;, &#39;foo&#39;, &#39;2000&#39;<br>
INSERT INTO liner_notes ( liner_id, notes) VALUES ( ?, ? ): &#39;6&#39;, &#39;foo&#39;<br>
COMMIT<br>
<br>
<br>
Cheers!<div class="HOEnZb"><div class="h5"><br>
<br>
______________________________<wbr>_________________<br>
List: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class" rel="noreferrer" target="_blank">http://lists.scsys.co.uk/cgi-b<wbr>in/mailman/listinfo/dbix-class</a><br>
IRC: <a href="http://irc.perl.org#dbix-class" rel="noreferrer" target="_blank">irc.perl.org#dbix-class</a><br>
SVN: <a href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/" rel="noreferrer" target="_blank">http://dev.catalyst.perl.org/r<wbr>epos/bast/DBIx-Class/</a><br>
Searchable Archive: <a href="http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk" rel="noreferrer" target="_blank">http://www.grokbase.com/group/<wbr>dbix-class@lists.scsys.co.uk</a></div></div></blockquote></div><br></div>