This project is archived and is in readonly mode.
Allow adapters to specify a limit on number of ids to allow in a single expression
Reported by alex (at alexrothenberg) | November 8th, 2010 @ 09:46 PM | in 3.0.5
When active record preloads associated records it can generate a long list in the sql. This patch allows an adapter to specify its limit and AR will then issue multiple queries if necessary.
For example if there were 1500 posts
Post.include(:comments)
will generate something like
select * from posts
select * from comments where post_id IN (1,2,3,4...999)
select * from comments where post_id IN (1001...1500)
With out the patch some databases (oracle I mean you) will give
errors when there are too many ids in the comments select (in
oracle more than 1000 causes error ORA-01795 - see http://ora-01795.ora-code.com/).
The patch is attached below or can be see on github at https://github.com/alexrothenberg/rails/tree/maximum_ids_in_list_fo...
Comments and changes to this ticket
-
Aaron Patterson November 18th, 2010 @ 05:04 PM
- Milestone cleared.
- Importance changed from to Low
-
Aaron Patterson November 18th, 2010 @ 06:01 PM
- State changed from new to committed
Applied, thanks!
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>