Dear monks,

is there any DBIC guru, who can help me out with following issue?

I can create DBIC object together with related objects by single create.

my $task = $rs_task->create({ name => 'Second task', subtask => { title => 'First subtask', .... } });

When a hashref is supplied as a value of relationship key, DBIC first perform search on related resultset then create (actually it calls find_or_create).

Is there a simple way how to prevent the search and create related object directly? For most of my relationships I never want to search for related objects when create. Sometime it is only the matter of performance (issuing useless select), but it can also trigger an error (related data contains BLOB fields).

Having one create I would broke the single statement into pieces but my application relies heavily on creation of whole object hierarchies just by supplying the hash of hashes, ... to create.

I had workaround (based on flagging the relationships by no_find_related flag and redefinition of $rs->find_or_new_related) which worked in DBIC 0.08010, but stopped working because find_or_new_related is not used in create (new, insert).

The only idea which came to my mind was to redefine $base_row_class->new ($rs->new_result?), $base_row_class->insert and handle the no_search relationships by myself. But I hope for a simpler solution with less code

I also noticed (observed inside DBIC) that in previous version of DBIC search could be prevented by supplying object instead of plain hash for relationship data. But this doesn't hold anymore.

my $task = $rs_task->create({ name => 'Second task', subtask => $subtask_rs->new({ title => 'First subtask', .... }) });

In reply to DBIC create - how to avoid search for related objects by roman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.