This queue is for tickets about the DBIx-Class CPAN distribution.

Report information
The Basics
Id:
59222
Status:
open
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
aleksey.mashanov [...] gmail.com
Cc:
AdminCc:

BugTracker
Severity:
(no value)
Broken in:
(no value)
Fixed in:
(no value)



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
On Fri Jul 09 09:21:30 2010, amashanov wrote:
Show quoted text
> 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
Thank you for pointing this out. Problem is in fact known, and there even was some preliminary code written, but tuits got scarce and I forgot about it. Will try to look into it again mid-August, if noone beats me to it.


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.