Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lookup polymorphic type from the column before the record (#1326)
Currently, `Relationship#type_for_source` looks up polymorphic source's type by: 1. Fetching its associated record. 2. Calling `.class._type` on that record. This approach is inefficient because usually, a polymorphic record (the `source`) has `_type` and `_id` columns. And the `_type` column's value will be the polymorphic relationship record's type. So this PR makes `type_for_source` check the type value from column before fetching the associated record.
- Loading branch information