aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/arel/delete_manager_test.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-09-30 18:30:47 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-09-30 21:21:54 +0900
commit859fba7c4bf7d33b4f9655914ed4bdc85380552e (patch)
treefd777f6b29c1b02575248e3dfe4cfcba13968472 /activerecord/test/cases/arel/delete_manager_test.rb
parent298629cefd845caf2cea28eb9cee2b538accc4ee (diff)
downloadrails-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/test/cases/arel/delete_manager_test.rb')
-rw-r--r--activerecord/test/cases/arel/delete_manager_test.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/activerecord/test/cases/arel/delete_manager_test.rb b/activerecord/test/cases/arel/delete_manager_test.rb
index 17a5271039..0bad02f4d2 100644
--- a/activerecord/test/cases/arel/delete_manager_test.rb
+++ b/activerecord/test/cases/arel/delete_manager_test.rb
@@ -15,6 +15,7 @@ module Arel
dm = Arel::DeleteManager.new
dm.take 10
dm.from table
+ dm.key = table[:id]
assert_match(/LIMIT 10/, dm.to_sql)
end