
Asking children of a new record results in a query
Reported by Ewout | August 7th, 2008 @ 08:47 AM
s = Selection.new s.baskets << Basket.new
logs: Thu, 07 Aug 2008 12:47:32 GMT ~ debug ~ SELECT "id", "title", "annotation", "selectionid" FROM "baskets" WHERE "selectionid" IN (NULL) ORDER BY "id"
Both Selection and Basket are models with a serial id.
There could be some cases where it is ok to launch a query asking for the associated children of a new resource: when the resource has a natural key and it already exists in the datastore.
The latter is a doubtful scenario however: saving the new resource if it already exists in the datastore will yield an error.
In any case, performing a query to find associated children of a new resource with an empty serial key is just overhead.
I included a patch that covers this case. Maybe it can be made more general, for example to never launch a query when the parent is a new_record.
Comments and changes to this ticket
-
Dan Kubb (dkubb) January 8th, 2009 @ 05:08 AM
- State changed from new to accepted
- Assigned user changed from Sam Smoot to Dan Kubb (dkubb)
-
Jonathan Stott (namelessjon) February 22nd, 2009 @ 07:53 AM
- Tag changed from dm-core, patch to dm-core, one_file_test, patch
- State changed from accepted to resolved
This is resolved in 0.10.0, see attached one file test.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »