mongodb / laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)
https://www.mongodb.com/compatibility/mongodb-laravel-integration
MIT License
6.96k stars 1.42k forks source link

PHPORM-175: Use foreign key name for MorphTo relationships #3011

Closed jmikola closed 2 weeks ago

jmikola commented 2 weeks ago

https://jira.mongodb.org/browse/PHPORM-175

Incorporates the proposed solution in mongodb/laravel-mongodb#2783 to not default $ownerKey to the current model's key name when constructing a MorphTo in HybridRelations::morphTo().

That change alone caused RelationsTest::testMorph() to fail, since MorphTo::addConstraints() would attempt to use a null ownerKey value. This required an additional change to fall back to the foreign key name when building the constraint.

Checklist