Using reserved word field name in DocumentDB

别说谁变了你拦得住时间么 提交于 2020-02-11 13:36:45

问题


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!


回答1:


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'



来源:https://stackoverflow.com/questions/30849310/using-reserved-word-field-name-in-documentdb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!