Closed cappuc closed 6 years ago
Thanks for pointing this out.
Indeed the embedsMany()
is not usable as it is on most SQL system, but the case is that some Database drivers (ie MongoDB) do not need this conversion, so I think we cannot generalize it. Also, my initial idea was to take advantage of new Mysql json
for this feature.
But I agree having the possibility to cast/uncast to json would be a great addition for DB layer not supporting json
type.
Let's make it optional : instead of calling asArray()
, we would call asJson()
method on the relationship object, so it's clear in which format the user wants his data stored in the database. What do you think ?
Yes, adding the asJson()
method can resolve the problem and allow the user to choice in which format the data is stored in the database
if I have some free time, I can try to implement the asJson()
method
I think, for consistency, this method should be available on both embedsOne
and embedsMany
relationships. Implementation should be pretty straightforward, still don't hesitate if you have any doubt or question.
Looks good @cappuc
EmbedsMany attributes must be array but the array needs to be serialized to json before generating sql query