You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.
Disclaimer: I know it's not recommended to use Laravel Model Uuids / Efficient Uuids as PK. I would happily discuss the situation if you open for a quick architectural debate, but let's keep the following example short. Err kinda.
Imagine I have three tables:
Carts have a unique customer id.
CartGroups: each Cart might have multiple CartGroups
Partners: each CartGroup is representing a Partner (aka seller or shop) in the customer's Cart.
Carts and CartGroups are native to the microservice (API) that handles them, they have unsigned BigInt ids (as PK). Partners, on the other hand, come from a different service and stored as-is for caching purposes. They have EfficientUuidids, therefore CartGroups have an EfficientUuid foreign key (partnerId) pointing to them.
And these are the generated queries as observed by Telescope:
select * from `carts` where `customerId` = 'abc123' limit 1
select * from `cartGroups` where `cartGroups`.`cartId` in (1) order by `id` asc
select * from `partners` where `partners`.`id` in (
'624a5b9b-62f3-51ce-8e3c-0d25bd61aa11',
'acad4fc6-45af-5c47-a7a9-d69fe069afad'
)
So no Partners loaded as the query uses uuids as string instead of binary.
Spent the day looking for others with similar problems and possible solutions, haven't found any, unfortunately. I'm not sure how to proceed, as I'm fairly new to Laravel / Eloquent. Also I understand this might be a feature request for a very narrow use case, but I'd happily implement it myself, if you'd be so kind to point me the right direction. ;)
Cheers.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Disclaimer: I know it's not recommended to use Laravel Model Uuids / Efficient Uuids as PK. I would happily discuss the situation if you open for a quick architectural debate, but let's keep the following example short. Err kinda.
Imagine I have three tables:
Carts
have a unique customer id.CartGroups
: eachCart
might have multipleCartGroups
Partners
: eachCartGroup
is representing aPartner
(aka seller or shop) in the customer'sCart
.Carts
andCartGroups
are native to the microservice (API) that handles them, they haveunsigned BigInt id
s (as PK).Partners
, on the other hand, come from a different service and stored as-is for caching purposes. They haveEfficientUuid
id
s, thereforeCartGroups
have anEfficientUuid
foreign key (partnerId
) pointing to them.Migration files:
Model definitions:
A simple controller to fetch a complete
Cart
(with all relations usingwith
) for a givencustomerId
:Tables are seeded with the following data:
This is the result (without timestamps):
And these are the generated queries as observed by Telescope:
So no
Partners
loaded as the query uses uuids as string instead of binary.Spent the day looking for others with similar problems and possible solutions, haven't found any, unfortunately. I'm not sure how to proceed, as I'm fairly new to Laravel / Eloquent. Also I understand this might be a feature request for a very narrow use case, but I'd happily implement it myself, if you'd be so kind to point me the right direction. ;)
Cheers.
The text was updated successfully, but these errors were encountered: