Hello everyone.
TL;DR
The Bucket.n1ql_query
code example in documentation
cb.n1ql_query('SELECT airportname, FROM
travel-sampleWHERE city=$1', "Reno")
does not work. Only
cb.n1ql_query(N1QLQuery('SELECT airportname, FROM
travel-sampleWHERE city=$1', "Reno"))
works.
I just started exploring couchbase with the python SDK (v2.5.1) and ran into a problem. According to the documentation, the Bucket.n1ql_query
accepts the query as string. It works fine until I start passing query with placeholders, e.g.
bucket.n1ql_query("select * from news where pub_date=$pub_d;", pub_d="2018-10-15")
which will complaint no value is found for the parameters. The placeholders work fine if I explicitly convert the query into N1QLQuery
,
bucket.n1ql_query(N1QLQuery("select * from news where pub_date=$pub_d;", pub_d="2018-10-15"))
Browsing through the source code here, I realize that only the query string is passed into N1QLQuery
constructor, and all the positional and keyword arguments are left out. My setup is listed as follow:
Python 3.6.6
C SDK: 2.10
Python SDK: 2.5.1
It looks like a bug to me, please correct me if this is actually behaving as expected.
Thanks,
Jeff