Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using reserved word field name in DocumentDB

I inherited a database loaded into DocumentDB, where field name happens to be "Value". Example of my structure is:

{
...
   "Alternates": [
      "Type": "ID",
      "Value" : "NOCALL"
   ]
}

when I query (using documentDB's SQL), trying to get back all documents where Alternates.Value = "NOCALL", I get syntax error near

"Value" error

. If I query for Type = "ID", it is all fine.

Seems that the word Value, having a special meaning on DocumentDB is causing an issue.

Putting punctuation (e.g. quotes/double quotes) around "Value" does not seem to help.

Any suggestion on how to resolve this will be much appreciated!

Thank you in advance!

like image 847
Alex Vilner Avatar asked Jun 15 '15 15:06

Alex Vilner


1 Answers

You are correct. Value is a reserved keyword. To escape this use [""] syntax.

So in your case of

"Alternates": [ "Type": "ID", "Value" : "NOCALL" ]

SELECT c FROM c JOIN alt IN c.Alternates WHERE alt["Value"] = 'NOCALL'

like image 127
Ryan CrawCour Avatar answered Sep 23 '22 07:09

Ryan CrawCour