This project is archived and is in readonly mode.
Chaining scopes can trigger excessive db queries
-
ender672
- Tag changed from 3.0 scopes to 3.0
-
Jeremy Kemper
- Milestone cleared.
- State changed from new to open
-
ender672
I was unable to find a reason for the current_scoped_methods_when_defined test in Scope#method_missing. All tests pass without it.
I am attaching an updated patch with a better unit test and that removes the current_scoped_methods_when_defined test.
-
Samuel Danielson
Thanks for the patch. Went from this
>> Cow.after('a').after('b').after('c').after('d').all Cow Load (0.5ms) SELECT "kine".* FROM "kine" WHERE (name > 'a') AND (name > 'b') Cow Load (0.2ms) SELECT "kine".* FROM "kine" WHERE (name > 'a') Cow Load (0.2ms) SELECT "kine".* FROM "kine" WHERE (name > 'a') AND (name > 'b') AND (name > 'c') Cow Load (0.2ms) SELECT "kine".* FROM "kine" WHERE (name > 'a') AND (name > 'b') AND (name > 'c') AND (name > 'd') => [#<Cow id: 1, name: "sam", created_at: "2010-02-25 05:04:04", updated_at: "2010-02-25 05:04:04">]to this! Happy cows.
>> Cow.after('a').after('b').after('c').after('d').all Cow Load (0.3ms) SELECT "kine".* FROM "kine" WHERE (name > 'a') AND (name > 'b') AND (name > 'c') AND (name > 'd') => [#<Cow id: 1, name: "sam", created_at: "2010-02-25 05:04:04", updated_at: "2010-02-25 05:04:04">] -
ender672
- Tag changed from 3.0 to 3
A patch similar to this (but sans test) looks to have been committed with 0be31f85639cf2f536c558819ef3ee45ba7d83a3.
Link here:
http://github.com/rails/rails/commit/0be31f85639cf2f536c558819ef3ee...I don't have permission to close the ticket, but this ticket is no longer needed.
-
Jeremy Kemper
- State changed from open to resolved
