Commit 20e051c
authored
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.1 parent ad64f14 commit 20e051c
1 file changed
+8
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
60 | 66 | | |
61 | 67 | | |
62 | 68 | | |
| |||
0 commit comments