Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

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

#5933

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...

Reported by alex (at alexrothenberg) · November 8th, 2010 @ 09:46 PM

State: committed
Milestone: 3.0.5
Assigned to: Aaron Patterson Aaron Patterson
Importance: Low

Activity

  1. Aaron Patterson
    Aaron Patterson
    • Milestone cleared.
    • Importance changed from to Low

    November 18th, 2010 @ 05:04 PM

  2. Aaron Patterson
    Aaron Patterson
    • State changed from new to committed

    Applied, thanks!

    November 18th, 2010 @ 06:01 PM

  3. Santiago Pastorino
  4. cschiewek
    cschiewek

    Any chance we could get this fix backported to 2.3?

    April 19th, 2011 @ 02:17 PM