Couchbase N1QL 更新时出现错误 3000。

huangapple go评论59阅读模式
英文:

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";

huangapple
  • 本文由 发表于 2020年1月3日 20:48:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/59578931.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定