Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-2730

Ensure that .sort method change criteria

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.1.0
    • Component/s: None
    • Labels:
      None

      Description

      This is not working on the latest version of mongoid:

       UserThemeVersion.where(parent_id: theme.id, user: current_user.id).sort(version: -1).first
      

      it was ignoring the sort on the first query.

      This pull request fix that issue. and also:

      1- .sort method was not changing the criteria, so when .first applied it assumed there was no sort and it was ignoring it

      2 - making apply_sorting a block function to unsure it will reset the query after execution of .first or .last

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            arthurnn Arthur Nogueira Neves
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: