hyperstack-org / hyperstack-org/hyperstack

foreign key in has_many broken

未关闭
#276 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
JavaScript
星标
538
派生
41
PR 合并指标
30 天内没有已合并 PR

描述

for example:

```ruby
belongs_to :duplicate_of, class_name: 'Report', required: false
has_many :duplicates, class_name: 'Report', foreign_key: 'duplicate_of_id'
```

breaks because of this code in the `ClassMethods#_react_param_conversion` method:

```ruby
assoc = associations.detect do |poly_assoc|
if key == poly_assoc.polymorphic_type_attribute
model_name = value
already_processed_keys << poly_assoc.association_foreign_key
elsif key == poly_assoc.association_foreign_key
model_id = value
already_processed_keys << poly_assoc.polymorphic_type_attribute
end
end
```

it is treating every relationship with a foreign key as a polymorphic relationship.

Clearly a regression when polymorphic was added

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。