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.

Quoting issues in AR's association preload

#602

If you look at the source code, there's even a FIXME there:

  1. FIXME: quoting

def preload_belongs_to_association(records, reflection, preload_options={})

The new eager loading mechanisms incorrectly quotes all primary keys when doing a preload. Obviously this shouldn't be done (at least) for integers and floats.

The information about the "numeric" columns [:integer, :float] was found in

ActiveRecord::ConnectionAdapters::Quoting#quote

This patch doesn't include tests (but didn't break any either) as I couldn't find a decent way to test this.

This is similar to this fix: http://dev.rubyonrails.org/chang... for Rails 1.x

Reported by Tiago Macedo · July 11th, 2008 @ 04:27 AM

State: resolved
Milestone: 2.x
Assigned to: Pratik Pratik
Importance: none

Activity

  1. Tiago Macedo
    Tiago Macedo

    Previous patch had a bug if the primary key was a float. This patch fixes it.

    July 11th, 2008 @ 03:45 PM

  2. Pratik
    Pratik
    • State changed from new to incomplete
    • Assigned user set to Pratik

    Hey Tiago,

    Could you add a failing test case in AR test suite please ? The test should fail before applying and pass after.

    Thanks.

    July 11th, 2008 @ 10:45 PM

  3. Tarmo Tänav
    Tarmo Tänav

    Squashed the commits, added test using features provided by #325 Add assert_query method to AR test_helper (assert_sql), also added quoting for the primary_key column. Also verified that test fails without the preload code changes.

    July 14th, 2008 @ 08:33 PM

  4. Tiago Macedo
    Tiago Macedo

    Thanks for the help.

    I didn't even notice the primary_key wasn't quoted ;)

    July 14th, 2008 @ 09:33 PM

  5. Repository
    Repository
    • State changed from incomplete to resolved

    (from [76df9fa0680d62ce41fa6f3b743c605101d101d2]) Fix integer quoting issues in association preload. [#602 state:resolved]

    Signed-off-by: Pratik Naik

    http://github.com/rails/rails/co...

    July 14th, 2008 @ 11:36 PM

  6. Repository
    Repository

    (from [84baada079fa7e68750c1e386f9849d2d47b59e1]) Fix integer quoting issues in association preload. [#602 state:resolved]

    Signed-off-by: Pratik Naik

    http://github.com/rails/rails/co...

    July 15th, 2008 @ 11:56 PM