This project is archived and is in readonly mode.

#4288 ✓wontfix
Alex Farrill

Model.last too clever when using CONCAT_WS in order

Reported by Alex Farrill | March 29th, 2010 @ 03:46 AM

My model has:

default_scope :order => "CONCAT_WS(' ', last_name, first_name)"

i.e. concat last name and first name for order

Calling Model.last, AR calls reverse_sql_order, which produces:

"CONCAT_WS(' ' DESC, last_name DESC, first_name) DESC"

which is no good. Maybe allow an override of the reverse sql order to be passed to default_scope or make reverse_sql_order aware of concat function?

Thanks,
Alex

Comments and changes to this ticket

  • Jeremy Kemper

    Jeremy Kemper March 29th, 2010 @ 07:31 AM

    • State changed from “new” to “wontfix”

    Better to avoid Model.last if you know you're using irreversible :order clauses.

    Note, that's a very expensive order that'll cause full table scans for every query.

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>

People watching this ticket

Pages