Merge pull request #35921 from Shopify/deduplicate-activerecord-strings

Deduplicate Active Record reflection names
This commit is contained in:
Rafael França 2019-04-11 17:51:11 -04:00 committed by GitHub
commit 644cd445c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -21,12 +21,12 @@ module ActiveRecord
def add_reflection(ar, name, reflection)
ar.clear_reflections_cache
name = name.to_s
name = -name.to_s
ar._reflections = ar._reflections.except(name).merge!(name => reflection)
end
def add_aggregate_reflection(ar, name, reflection)
ar.aggregate_reflections = ar.aggregate_reflections.merge(name.to_s => reflection)
ar.aggregate_reflections = ar.aggregate_reflections.merge(-name.to_s => reflection)
end
private