Request for Review: Ticket #10686

http://dev.rubyonrails.org/ticket/10686

I'd really appreciate it if a few people would test patch this out and give feedback.

It changes the SQL generated by update_all so that passing :limit or :order options will work with non-MySQL adapters. The SQL currently generated creates SQL Exceptions for non-MySQL adapters.

Added tests pass for MySQL, PostgreSQL, and Sqlite3; I'm working on tests to run (period) for other adapters, so testing those would be most helpful.

Verification, comments, and +1s would be appreciated!

Thanks! Brendan

The :limit and :order options are meant to apply to the UPDATE statement directly -- simply don't use them with databases that don't support it.

The issue you're seeing is that :limit and :order are being pulled from the association scope -- this is a bug, IMO, and should be fixed rather than adding roundabout support for a niche feature.

See MySQL :: MySQL 8.0 Reference Manual :: 13.2.13 UPDATE Statement for why you sometimes want to use UPDATE ... ORDER BY with MySQL. It works around duplicate key errors.

Best, jeremy