SOQL Error and Functionality Changes

Updates in this release (Winter 25) may affect existing Apex code that depends on older SOQL error messages and behavior, especially if your code parses error messages from dynamic SOQL queries. Be sure to review these updates and make any necessary changes to your code.

Applicable Editions: These updates apply to all editions.

Action Required: Examine the changes to error messages and functionality, and update your code as needed.

Key Changes:

1. Support for Negative Currency Values in Dynamic SOQL Queries

Dynamic SOQL queries in multi-currency orgs now support negative currency values. Example:

SELECT Name FROM Invoice__c WHERE Balance__c < USD-500

2. New Error Messages for Invalid Dynamic SOQL Queries

Example 1:

SELECT Id FROM Account USING everything
  • Old Message: unexpected token: ‘<EOF>’
  • New Message: unexpected token: ‘everything’

Example 2:

SELECT ParentId, Value FROM InteractionRefOrValue WHERE ParentId IN ()
  • Old Message: unexpected token: ‘)’
  • New Message: unexpected token: ‘ParentId IN ()’

Example 3:

SELECT FROM ServicePresenceStatus
  • Old Message: unexpected token: ‘FROM’
  • New Message: unexpected token: ‘SELECT FROM’

Example 4:

SELECT Id from $casecomment WHERE isdeleted = false
  • Old Message: line 1:15 no viable alternative at character ‘$’
  • New Message: line 1:15 unexpected token: ‘$’

Example 5:

SELECT lastmodifieddate, companyna fr$om user
  • Old Message: unexpected token: user
  • New Message: missing value at ‘user’

3. Quotes Around Unexpected Tokens

Example:

SELECT annualrevenue, parentid 
FROM Account 
WHERE 
   (isDeleted = false AND NumberOfEmployees != 100) 
   OR (isDeleted = false AND Site = '999') 
   AND ParentId = '000000000000000' 
LIMIT 50000
  • Old Message: unexpected token: AND
  • New Message: unexpected token: ‘AND’

4. NULL Literals in WHERE Clauses with LIKE Keyword

Example:

SELECT Id, Name, Country__c, State__c, City__c, PAN_Number__c 
FROM Account 
WHERE PAN_Number__c LIKE NULL AND Name LIKE '%a%'
  • Old Message: invalid operator
  • New Message: unexpected token: ‘NULL’

5. Nested Functions in Dynamic SOQL Queries

Example:

SELECT convertCurrency(calendar_year(convertTimezone(lastmodifieddate))) FROM Account
  • Old Message: expecting a right parentheses, found ‘(‘
  • New Message: unexpected token: ‘(‘

6. Invalid Datetime Literals

Example 1:

SELECT Id FROM Account WHERE SystemModstamp > 2020-12-12t12:12:00-25:00
  • Old Message: line 1:67 mismatched character ‘5’ expecting set ‘0’..’3′
  • New Message: Invalid datetime: 2020-12-12t12:12:00-25:00

Example 2:

SELECT Id FROM Account WHERE SystemModstamp > 2020-52-12t12:12:00-05:00
  • Old Message: line 1:51 no viable alternative at character ‘5’
  • New Message: Invalid datetime: 2020-52-12t12:12:00-05:00

7. Bind Variable Reference Errors

Example:

SELECT Id FROM Custom_User_Attribute__c WHERE User__c =: 0050W000007Jz7jQAC
  • Old Message: Only variable references are allowed in dynamic SOQL/SOSL
  • New Message: unexpected token: ‘0050’

Ensure your dynamic SOQL queries align with these updated behaviors to avoid unexpected issues.

Leave a Comment