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.

Spaces at end of association :order options causes error

#1388

Out of habit, I've been using spaces around all :condition and :order strings in my has_many associations. SQL doesn't mind extra spaces and I always fear a string being joined without a space causing some unforseen error.

ActiveRecord::Base#reverse_sql_order, though, causes an error for me when calling some_has_many_association.last for an association that has an :order option that ends in " asc " by adding an extra "DESC" to the order string of the query.

Adding a check for spaces to the regexes of reverse_sql_order fixes it for me. See patch...

Reported by John Devine · November 16th, 2008 @ 11:47 PM

State: wontfix
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Pratik
    Pratik
    • Tag changed from :order, activerecord, associations, has_many to :order, activerecord, associations, has_many, patch
    • Title changed from PATCH: spaces at end of association :order options causes error to Spaces at end of association :order options causes error

    March 7th, 2009 @ 03:40 PM

  2. Pratik
    Pratik
    • State changed from new to wontfix

    I don't think using spaces is normal. Closing the ticket as it all works fine when no spaces are used. Don't think it's worth complicating.

    Thanks.

    March 7th, 2009 @ 03:41 PM