topclaudy / compoships

Multi-columns relationships for Laravel's Eloquent ORM
MIT License
1.12k stars 132 forks source link

BelongsTo's use of attributesToArray is causing issues #86

Closed nik-418 closed 4 years ago

nik-418 commented 4 years ago

Hi there!

First of all - great package!

On line 41 of the BelongsTo subclass, child attributes are fetched using the attributesToArray() method. However, what ends up happening is that custom getFooAttribute($value) mutators get triggered.

As far as I can tell, the only follow-on usage is for null checks, but getAttributes() should suffice for that, I think.

Was there a specific reason for choosing attributesToArray() specifically?

The reason I'm looking at this as a possible bug is that in a fairly large and complex project, we've rolled our own solution to the multi-column relationships problem (domain-specific; using trait comparisons). It has been in production for the last year and a half and we're exploring Compoships as a possible replacement to reduce code complexity on our end.

Some tests started failing in our pipeline with this experiment. Some of those failures are to be expected, while others - like the one related to this issue - are not.

Thanks in advance. :)

topclaudy commented 4 years ago

Fixed in 2.0.1. Thanks for reporting this.