-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lb3 - Relations on uuid #4287
Comments
Maybe here is same issue on LB4 loopbackio/loopback-next#3602 that seems to be solved |
Thank you for reporting the issue. Since it's related to LoopBack 3.x, I am going to move it to |
This looks like a reasonable assumption to me. Can you try to apply loopbackio/loopback-datasource-juggler#1783 to the juggler module installed in your dependencies and then add |
Thank you for your reply. Then edited
But I get same results, uuid NaN. |
Hmm, then the problem may be somewhere else. |
The juggler always look at the id prop, so adding
UPDATE: works even without
|
Although the model relations now seem to work fine, most of the methods don't. For ex
While in the db the entry is:
|
@fasenderos I think LB3 takes the id property as the source key by default. That's why when set the uuid property to Customer
Address
I am also curious about the result of |
@agnes512 first I post my model def without your suggestions Customer
Address
Then I create a boot script /boot/test.js
|
@agnes512 with your suggestions the Customer
Address
Edited boot script /boot/test.js
|
@fasenderos sorry I made a mistake! Both relation definitions in my suggestion should be :
Could you try it one more time? thanks! uuid should be working fine when it's the id property. Just need to check if it's possible to customize the primary key in LB3 so that we can have both int type |
@agnes512 great! Now it works, thanks for your help! |
Great!! :D As for your first definition, I think the problem happens when you do the creation.
Type of If you would like have auto increment id (as the id property) and auto-generated uuid, use the
with this definition, you can create instances without defining
both |
No no, I never create customer with the However I understand the point. Thanks so much! |
Feel free to re-open the issue in case it is not solved yet. |
Steps to reproduce
When the
foreignKey
of the relations point to ID everything works as expected, while if I try to point the foreignKey to UUID, the UUID is parsed as integer (NaN) and the relation not work.To reproduce create 2 models:
Customer
Address
Get customer with address related by ID:
Now in
Address
replace"foreignKey": "customerId"
with"foreignKey": "customerUuid"
and you getcustomerUuid
as NaN:If you do the same thing for
Customer
model by replacing the"foreignKey": "customerId"
with"foreignKey": "customerUuid"
, you get an empty addresses listExpected Behavior
The ability to use UUID on to relate model
Additional information
The text was updated successfully, but these errors were encountered: