Subject: | Unnecessary pre-reconstruction on insert |
insert() for related row led to fetching of previously inserted relating
row from database.
I have two result classes: Entity (entities) and Log::Entity
(entity_log), Entity->has_many(log => Log::Entity).
And do something like this:
my $x = Entity->new({...});
$x->insert();
$x->add_to_log({...});
Debug trace is following (with DBIC_TRACE and DBIC_MULTICREATE_DEBUG):
X::Result::Entity=HASH(0xa1b4220) inserting (...)
INSERT INTO "entities" ( ... ) VALUES ( ... ): ...
X::Result::Entity=HASH(0xa1b4220) fetching missing PKs id
X::Result::Log::Entity=HASH(0x86f826c) pre-reconstructing entity
X::Result::Entity=HASH(0xa3fc208)
SELECT ... FROM "entities" "me" WHERE ( "me"."id" = ? ): '224855'
X::Result::Log::Entity=HASH(0x86f826c) inserting (...)
INSERT INTO "entity_log" ( "entity_id", ... ) VALUES ( ?, ... ):
'224855', ...
X::Result::Log::Entity=HASH(0x86f826c) fetching missing PKs id