laravel-mongodb
laravel-mongodb copied to clipboard
fix: morphTo when relation name is in camel case
Commit e19e10a in this PR updates existing tests to use a 'multi-word' relation for the morph relationship. This means that:
-
imageable
is changed tohas_image
when passed as the$name
parameter tomorphOne()
andmorphMany()
Note that snake case is required here - the parent EloquentgetMorphs()
method constructs the expected column names by appending '_id' and '_type' to the name that's passed. -
imageable
is changed tohasImage
when accessed as the relation name
That commit causes RelationsTest::testMorph()
to fail, then commit c02e584 fixes the issue in line with how Eloquent's morphTo()
method works, where $name
variable defaults to the name of the calling function and is only snake-cased when passed to getMorphs()
(reference)
Codecov Report
Merging #2318 (e26c877) into master (6aa6ad1) will not change coverage. The diff coverage is
100.00%
.
@@ Coverage Diff @@
## master #2318 +/- ##
=========================================
Coverage 88.12% 88.12%
Complexity 664 664
=========================================
Files 33 33
Lines 1566 1566
=========================================
Hits 1380 1380
Misses 186 186
Impacted Files | Coverage Δ | |
---|---|---|
src/Eloquent/HybridRelations.php | 93.58% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 6aa6ad1...e26c877. Read the comment docs.
This was merged in #2498.
Thanks!