在DocumentDB中使用保留字字段名称 [英] Using reserved word field name in DocumentDB
问题描述
我继承了一个加载到DocumentDB中的数据库,其中字段名称恰好是"Value". 我的结构示例是:
I inherited a database loaded into DocumentDB, where field name happens to be "Value". Example of my structure is:
{
...
"Alternates": [
"Type": "ID",
"Value" : "NOCALL"
]
}
当我查询(使用documentDB的SQL)时,尝试找回所有文件,其中Alternates.Value = "NOCALL",
我在
when I query (using documentDB's SQL), trying to get back all documents where Alternates.Value = "NOCALL",
I get syntax error near
值"错误
.如果我查询Type = "ID",
很好.
似乎在DocumentDB上具有特殊含义的Value一词引起了问题.
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!
提前谢谢!
推荐答案
您是正确的.值是保留关键字. 为了避免这种情况,请使用["]语法.
You are correct. Value is a reserved keyword. To escape this use [""] syntax.
所以在您的情况下
备用项":[ 类型":"ID", 值":"NOCALL" ]
"Alternates": [ "Type": "ID", "Value" : "NOCALL" ]
选择c 来自c 加入ALT in c.Alternates 在哪里alt ["Value"] ='NOCALL'
SELECT c FROM c JOIN alt IN c.Alternates WHERE alt["Value"] = 'NOCALL'
这篇关于在DocumentDB中使用保留字字段名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!