7
votes

I've got a Cosmos DB collection with a document that contains properties that have a special character and what I assume is a reserved word. An example document is:

{
   $type: 'Some value', 
   Value: 'Some other value'
}

If I execute the following query in the Azure Portal Query Explorer:

select * from c where c.Value = 'Some other value'

I receive an error of "Syntax error, incorrect syntax near 'Value'.". I get a similar error querying on c.$type.

How do I escape these property values so that I can query?

1

1 Answers

14
votes

In the case of special characters, you will need to wrap the property inside []

Example:

SELECT * FROM c WHERE c["$type"] = "Some value"

SELECT * FROM c WHERE c["value"] = "$Some other value"