class method self.shuffle_unordered_selects

Ruby on Rails edge

Since edge

Shuffles the rows of every SELECT Active Record generates that has no +ORDER BY+ clause.

The order of such a query is not specified, and databases are free to return its rows in any order. Enabling this option makes that explicit, so code (and tests) that accidentally rely on the order a given database happens to return today fails loudly instead of breaking later.

It is meant to be enabled in the test or development environments only.

Rows are shuffled after the database has returned them, so queries built from raw SQL strings are left untouched (Active Record cannot tell whether they are ordered), and queries ending in +LIMIT 1+ are unaffected because the database has already picked the row.

Source
# File activerecord/lib/active_record.rb, line 415
  singleton_class.attr_accessor :shuffle_unordered_selects

Defined in activerecord/lib/active_record.rb line 415 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close