mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #36706 from kirs/dedup-optimizer-hints
[ActiveRecord] Deduplicate optimizer hints
This commit is contained in:
commit
2caddbf8ae
2 changed files with 8 additions and 1 deletions
|
@ -952,7 +952,7 @@ module ActiveRecord
|
|||
def optimizer_hints!(*args) # :nodoc:
|
||||
args.flatten!
|
||||
|
||||
self.optimizer_hints_values += args
|
||||
self.optimizer_hints_values |= args
|
||||
self
|
||||
end
|
||||
|
||||
|
|
|
@ -363,6 +363,13 @@ module ActiveRecord
|
|||
assert_match %r{/\*\+ BADHINT \*/}, post_with_hint.to_sql
|
||||
end
|
||||
|
||||
def test_does_not_duplicate_optimizer_hints_on_merge
|
||||
escaped_table = Post.connection.quote_table_name("posts")
|
||||
expected = "SELECT /*+ OMGHINT */ #{escaped_table}.* FROM #{escaped_table}"
|
||||
query = Post.optimizer_hints("OMGHINT").merge(Post.optimizer_hints("OMGHINT")).to_sql
|
||||
assert_equal expected, query
|
||||
end
|
||||
|
||||
class EnsureRoundTripTypeCasting < ActiveRecord::Type::Value
|
||||
def type
|
||||
:string
|
||||
|
|
Loading…
Reference in a new issue