[SalesForce] get a DisjunctionsNotSupportedException when doing a SOQL query on Custom Metadata

I'm performing this query against a Custom Metadata object:

SELECT Call_Center_Display_Script__c
FROM VDN_Mapping__mdt 
WHERE VDN__c = '99999' OR DNIS__c = '123456786' 
LIMIT 1

But I'm getting this error from Salesforce:

An error has occurred in the following section: [Exception, DisjunctionsNotSupportedException_desc]. Salesforce.com has been notified of this error.

Why does this occur and how can I resolve this?

Best Answer

Custom Metadata supports a limited SOQL syntax, and "OR" statements are not supported. From the documentation:

Custom metadata types support the following SOQL query syntax.

SELECT fieldList [...]
FROM objectType
    [USING SCOPE filterScope]
[WHERE conditionExpression]
[ORDER BY field {ASC|DESC} [NULLS {FIRST|LAST}] ]
  • The fieldList can include only non-relationship fields.
  • FROM can include only one object.
  • You can’t use COUNT with custom metadata types.
  • You can use the following operators.
    • IN and NOT IN
    • =, >, >=, <, <=, and !=
    • LIKE, including wild cards
    • AND
  • You can use ORDER BY, ASC, and DESC with multiple fields.

Notice that "OR" is not supported. Apparently that's called a "Disjunction"