Hello,
When trying to execute a N1QL query using python sdk (3.0.3), using named parameters always results in “No value for named parameter $foo” even though I use the syntax suggested by the docs: https://docs.couchbase.com/python-sdk/current/howtos/n1ql-queries-with-sdk.html
>>> clu = cast(Any, cluster).Cluster.connect(
... f"couchbase://{cfg.COUCHBASE_HOST}:{cfg.COUCHBASE_PORT}",
... cast(Any, cluster).ClusterOptions(
... cast(Any, cluster).PasswordAuthenticator(cfg.COUCHBASE_USER, cfg.COUCHBASE_PASSWORD)
... )
... )
>>> collection = clu.bucket(bucket_name).default_collection()
>>> list(collection.query("""SELECT META().id FROM `data` WHERE META().id=$foo""", foo='ud/1/data'))
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python3.8/dist-packages/couchbase_core/n1ql.py", line 529, in __iter__
raw_rows = self.raw.fetch(self._mres)
couchbase.exceptions.CouchbaseException: <RC=0xCD[LCB_ERR_INTERNAL_SERVER_FAILURE (205)], HTTP Request failed. Examine 'objextra' for full result, Results=1, C Source=(src/pycbc_http.c,206), OBJ=ViewResult<rc=0xCD[LCB_ERR_INTERNAL_SERVER_FAILURE (205)], value={'requestID': 'd014e750-ee23-4308-98fb-4ba2f03d8d43', 'clientContextID': 'aff4f1a5ed0d87fe', 'signature': {'id': 'json'}, 'results': [], 'errors': [{'code': 5010, 'msg': 'Error evaluating span. - cause: No value for named parameter $foo.'}], 'status': 'errors', 'metrics': {'elapsedTime': '2.201548ms', 'executionTime': '2.030013ms', 'resultCount': 0, 'resultSize': 0, 'errorCount': 1}}, http_status=0, tracing_context=0, tracing_output=None>, Context={'first_error_code': 5010, 'http_response_code': 200, 'first_error_message': 'Error evaluating span. - cause: No value for named parameter $foo.', 'statement': 'SELECT META().id FROM `data` WHERE META().id=$foo', 'client_context_id': 'aff4f1a5ed0d87fe', 'query_params': '', 'http_response_body': '', 'endpoint': 'localhost:8093', 'type': 'QueryErrorContext'}, Tracing Output={":nokey:0": null}>
Is this a bug or has the query syntax changed?