英文:
couchbase n1ql update gives error 3000 when updating
问题
我有一个存储在名为dev_hostels的存储桶中的couchbase文档,其结构如下:
{
"updatedAt": "2019-12-24T12:30:07.175Z",
"data": {
"type": {
"value": "n/a"
}
}
}
n1ql更新查询
UPDATE dev_hostels
set data.type.value = "GUEST_HOUSE", updatedAt = NOW_MILLIS() where meta().id = "HOSTEL:1";
或者
UPDATE dev_hostels
USE KEYS "HOSTEL:1" SET data.type.value = "GUEST_HOUSE", updatedAt = NOW_MILLIS() RETURNING meta().id;
但是我收到了以下错误
"code": 3000,
"msg": "语法错误 - 在value处"
英文:
I have a couchbase document with this structure stored in a bucket named dev_hostels:
{
"updatedAt": "2019-12-24T12:30:07.175Z",
"data": {
"type": {
"value": "n/a"
}
}
}
The n1ql update query
UPDATE `dev_hostels` set data.type.value = "GUEST_HOUSE", updatedAt = NOW_MILLIS() where meta().id = "HOSTEL:1";
or
UPDATE `dev_hostels` USE KEYS "HOSTEL:1" SET data.type.value = "GUEST_HOUSE", updatedAt = NOW_MILLIS() RETURNING meta().id;
but I got this error
"code": 3000,
"msg": "syntax error - at value",
答案1
得分: 2
value 是一个关键字,所以你必须像这样使用反引号进行转义:
UPDATE `dev_hostels` SET data.type.`value` = "GUEST_HOUSE", updatedAt = NOW_MILLIS() WHERE meta().id = "HOSTEL:1";
英文:
value is a keyword, so you have to use escape it with backticks as well
UPDATE `dev_hostels` set data.type.`value` = "GUEST_HOUSE", updatedAt = NOW_MILLIS() where meta().id = "HOSTEL:1";
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论