Skip Menu |
 

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

Report information
The Basics
Id: 59222
Status: open
Priority: 0/
Queue: DBIx-Class

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

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Unnecessary pre-reconstruction on insert
Download (untitled) / with headers
text/plain 893b
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
Download (untitled) / with headers
text/plain 1.1k
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 is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

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