aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/schema
diff options
context:
space:
mode:
authorLauro Caetano <laurocaetano1@gmail.com>2014-04-23 23:51:00 -0300
committerLauro Caetano <laurocaetano1@gmail.com>2014-05-20 23:26:51 -0300
commit4debc86bd329d31360272ed15459cde3b9af3a10 (patch)
tree2743821dedf9539da64989fc9e9e79b4e1405d75 /activerecord/test/schema
parentb17f6e6877162648936c32e62c58305861beaf70 (diff)
downloadrails-4debc86bd329d31360272ed15459cde3b9af3a10.tar.gz
rails-4debc86bd329d31360272ed15459cde3b9af3a10.tar.bz2
rails-4debc86bd329d31360272ed15459cde3b9af3a10.zip
Fix polymorphic eager load with foreign_key as String.
The foreign_key could be `String` and just doing `owners_map[owner_key]` could return `nil`. To prevent this bug, we should `to_s` both keys if their types are different. Fixes #14734.
Diffstat (limited to 'activerecord/test/schema')
-rw-r--r--activerecord/test/schema/schema.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb
index 9e511af3bd..67ba358843 100644
--- a/activerecord/test/schema/schema.rb
+++ b/activerecord/test/schema/schema.rb
@@ -187,6 +187,9 @@ ActiveRecord::Schema.define do
t.integer :taggings_count, default: 0
t.integer :children_count, default: 0
t.integer :parent_id
+ t.references :author, polymorphic: true
+ t.string :resource_id
+ t.string :resource_type
end
create_table :companies, force: true do |t|