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.

Model.last too clever when using CONCAT_WS in order

#4288

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

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

State: wontfix
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Jeremy Kemper
    Jeremy Kemper
    • 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.

    March 29th, 2010 @ 07:31 AM