Error on preparestatment at N1QL when the field starts with "_"

To try to run my query, first I create the document at default bucket:

{
  "name": "Poliana",
  "city": "Salvador",
  "_id": "id"
}

And then I ran this code:

JsonObject params = JsonObject.create().put("_id","id");
 Statement statement = Select.select("*").from(i("default"))
                .where(x("_id").eq(x('$' + "_id")));

That does not return the result, but when I do the query, but finding by name, “name”: “Poliana”, that works.

my client version is: 2.4.1

Note that this isn’t a prepared statement. That’s handled by adhoc() on the query options.

If you just print out the statement to the console/log, how does it appear? Does that then work in either cbq or the web console?

ParameterizedN1qlQuery n1qlQuery = N1qlQuery.parameterized(statement, params);

The toString objects:

  • n1qlQuery.toString(): ParameterizedN1qlQuery{statement=SELECT * FROM default WHERE _id = $_id, params={"_id":“id”}}
  • statement :SELECT * FROM default WHERE _id = $_id
  • params: {"_id":“id”}

@daschl does this look like the Java client is doing something unusual with the leading _? Note that the statement doesn’t have the _.