This project is archived and is in readonly mode.

#1388 ✓wontfix
John Devine

Spaces at end of association :order options causes error

Reported by John Devine | November 16th, 2008 @ 11:47 PM | in 2.x

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

Comments and changes to this ticket

  • Pratik

    Pratik March 7th, 2009 @ 03:40 PM

    • 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”
  • Pratik

    Pratik March 7th, 2009 @ 03:41 PM

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


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=""></a>