-
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
Loopback standard model REST endpoints automatically round BIGINT params #2352
Comments
@raymondfeng are there still plans to land #1221? Maybe someone else should take it over if not. @bajtos, is this related to coercion clean-up in strong-remoting? Do you have any PRs that fix the issue? |
@richardpringle I think it may be related to coercion clean-up, thank you for pointing it out! |
This problem has been fixed by #343 in LoopBack 3.0 (alpha). When converting "any"-typed argument from a string-source like a query string, we preserve string values that are too large to store in an integer (greater than |
@bajtos Any chance this can this be backported to 2.x? We've been bitten by this a couple of times. |
@lukewendling @justinlueders I think this is the place where to fix the problem in 2.x, if you feel like contributing the fix yourself: |
I am using version loopback ver 3.22.0 with loopback-connector-mssql ver 3.3.0. "objectId": { (notice the "id":true and "dataType": "bigint") Changing the id property to false fixes the issue, but loopback does not allow models with no id when connecting a DB, I used a very unprofessional work around at the moment) Is this issue still marked as an open bug? |
Summary
This one is causing me a lot of pain.
After a lot of debugging it looks like Loopback is automatically assuming an ID value on the URI (e.g.
/api/myModel/:id
) is a Number.So something like this:
curl -X GET --header "Accept: application/json" "http://192.168.99.100:3000/api/profiles/5828128208445124611"
Does not work because Loopback is automatically converting the BIGINT value to Number, which rounds
5828128208445124611
to5828128208445125000
.So the above GET request example, results in an error:
Enabling debugging output in Loopback shows:
So clearly the value
4828128208445124611
gets rounded into4828128208445125000
.I verified that this happens right at the beginning, using an operations hook:
The output shows the ID is already truncated:
Is this a known issue? I couldn't find documentation or bug reports etc. on this.
Custom Remote Method
Btw, adding my own remoteMethod where I have control over the Input Argument (i.e. forcing it to be a string) and then calling findById programmatically works correctly:
You can see above I simply am copying the default findById REST endpoint, only difference is I add
get
to the end of the URI/api/profiles/:id/get
. The logic just defers to Profile.findById().Calling it:
Works with no issues.
The text was updated successfully, but these errors were encountered: