diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-09-30 18:30:47 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-09-30 21:21:54 +0900 |
commit | 859fba7c4bf7d33b4f9655914ed4bdc85380552e (patch) | |
tree | fd777f6b29c1b02575248e3dfe4cfcba13968472 /activerecord/lib/arel/nodes/update_statement.rb | |
parent | 298629cefd845caf2cea28eb9cee2b538accc4ee (diff) | |
download | rails-859fba7c4bf7d33b4f9655914ed4bdc85380552e.tar.gz rails-859fba7c4bf7d33b4f9655914ed4bdc85380552e.tar.bz2 rails-859fba7c4bf7d33b4f9655914ed4bdc85380552e.zip |
Handle DELETE with LIMIT in Arel
MySQL supports DELETE with LIMIT and ORDER BY.
https://dev.mysql.com/doc/refman/8.0/en/delete.html
Before:
```
Post Destroy (1.0ms) DELETE FROM `posts` WHERE `posts`.`id` IN (SELECT `id` FROM (SELECT `posts`.`id` FROM `posts` WHERE `posts`.`author_id` = ? ORDER BY `posts`.`id` ASC LIMIT ?) __active_record_temp) [["author_id", 1], ["LIMIT", 1]]
```
After:
```
Post Destroy (0.4ms) DELETE FROM `posts` WHERE `posts`.`author_id` = ? ORDER BY `posts`.`id` ASC LIMIT ? [["author_id", 1], ["LIMIT", 1]]
```
Diffstat (limited to 'activerecord/lib/arel/nodes/update_statement.rb')
-rw-r--r-- | activerecord/lib/arel/nodes/update_statement.rb | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/activerecord/lib/arel/nodes/update_statement.rb b/activerecord/lib/arel/nodes/update_statement.rb index 5184b1180f..017a553c4c 100644 --- a/activerecord/lib/arel/nodes/update_statement.rb +++ b/activerecord/lib/arel/nodes/update_statement.rb @@ -3,8 +3,7 @@ module Arel # :nodoc: all module Nodes class UpdateStatement < Arel::Nodes::Node - attr_accessor :relation, :wheres, :values, :orders, :limit - attr_accessor :key + attr_accessor :relation, :wheres, :values, :orders, :limit, :key def initialize @relation = nil |