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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |