Trying to query a number field without decimals via soql using a where clause with a number greater than 2147483647 will fail
Last updated 2022-01-19 ·Reference W-4622947 ·Reported By 18 users
In Review
Summary
If you have a number field and try to query it using SOQL or REST and try to have a where clause with a number greater than 2147483647 the query will fail.
What happens is that with a number field in SOQL, the Apex parser parses without scale as integer instead of checking field definition.
Repro
1. Add field "Quantity" into the page layout and make FLS(field level access) visible for current user.
2. Create an Opportunity with Quantity as 2147483648 and save it.
3. Using workbench or developer console to run the SOQL query. (Note that "Quantity" API name is TotalOpportunityQuantity)
SELECT TotalOpportunityQuantity FROM OPPORTUNITY WHERE TotalOpportunityQuantity >= 2147483648
Observe error: For input string: "2147483648"
4. Change the SOQL query as:
SELECT TotalOpportunityQuantity FROM OPPORTUNITY WHERE TotalOpportunityQuantity >= 2147483648.00
Observe: executes without issue
Expected behavior: executes without error for the first query.
Workaround
Workaround: Change the input value to decimal with scale.
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.