diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-08-28 18:09:00 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-08-28 18:09:00 -0700 |
commit | ef724e41a2e53ff786f2ff9a145815b29a985b4f (patch) | |
tree | b4fce7a6d8fcd60247957506729f866ba2dc1751 /activerecord/lib/active_record/associations/preloader/has_and_belongs_to_many.rb | |
parent | c0c4d276885553b2bd6f911b28c128c67a64045c (diff) | |
download | rails-ef724e41a2e53ff786f2ff9a145815b29a985b4f.tar.gz rails-ef724e41a2e53ff786f2ff9a145815b29a985b4f.tar.bz2 rails-ef724e41a2e53ff786f2ff9a145815b29a985b4f.zip |
correctly typecast keys, remove conditionals, reduce object allocations
Diffstat (limited to 'activerecord/lib/active_record/associations/preloader/has_and_belongs_to_many.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/preloader/has_and_belongs_to_many.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/preloader/has_and_belongs_to_many.rb b/activerecord/lib/active_record/associations/preloader/has_and_belongs_to_many.rb index 08a36db877..c042a44b21 100644 --- a/activerecord/lib/active_record/associations/preloader/has_and_belongs_to_many.rb +++ b/activerecord/lib/active_record/associations/preloader/has_and_belongs_to_many.rb @@ -40,6 +40,11 @@ module ActiveRecord end end + def type_caster(results, name) + caster = results.column_types.fetch(name, results.identity_type) + lambda { |value| caster.type_cast value } + end + def build_scope super.joins(join).select(join_select) end |