Couchbase Query on numeric property name in sub document

57 Views Asked by At

I have documents that look like :

{
  "mobile": {
    "default": {
      "s": {
        "camp": {
          "100112": 0,
          "100114": 0,
          "100122": 0
        },
        "score": 1
      }
    }
  }
}

And I want to select a document with some criteria like :

select * from my_bucket where mobile.default.s.camp.100112 = 0

But I got a syntax error :

[
  {
    "code": 3000,
    "msg": "syntax error - at 100112",
    "query_from_user": "select  * from `user_scoring_sample` t where mobile.default.s.camp.100112 = 0"
  }
]

Is it allowed to have numeric property name ? do we have to escape them in a n1ql query ?

1

There are 1 best solutions below

0
On

You can escape keywords, tables/properties with special characters, and numeric tables/properties using the backtick character `.

For example:

SELECT * FROM my_bucket where mobile.default.s.camp.`100112` = 0