我正在尝试使用javascript驱动程序执行这样的查询:
client.execute('SELECT * FROM zhos_dev.jw_testing WHERE a IN ?', [['foo', 'foo1']], {prepare: true})
它给了我: ResponseError: line 0:-1 mismatched input '<EOF>' expecting ')'
.
我的版本是: [cqlsh 3.1.8 | Cassandra 1.2.19 | CQL spec 3.0.5 | Thrift protocol 19.36.2]
该表已创建并填充了以下cql:
CREATE TABLE zhos_dev.jw_testing (a text PRIMARY KEY, b text);
INSERT INTO zhos_dev.jw_testing (a, b) VALUES ('foo', 'bar');
INSERT INTO zhos_dev.jw_testing (a, b) VALUES ('foo1', 'bar1');
INSERT INTO zhos_dev.jw_testing (a, b) VALUES ('foo2', 'bar2');
2条答案
按热度按时间eulz3vhy1#
这个问题在faq中,但在实际通话的文档中没有,我在stackoverflow上很难找到它,所以我想把它复制到这里:
引用https://docs.datastax.com/en/developer/nodejs-driver/4.1/faq/#how-can-i-use-a-list-of-values-with-the-in-operator-in-a-where-子句:
在查询中使用in运算符,后跟不带括号的问号占位符。包含值列表的参数应该是数组的示例。
0md85ypi2#
我在同一个版本中复制了这一点:[cqlsh 3.1.8 | cassandra 1.2.19 | cql spec 3.0.5 | thrift protocol 19.36.2]
早在cassandra 2.1中,“in”子句就可以正常工作:[cqlsh 5.0.1 | cassandra 2.1.21 | cql spec 3.2.1 | native protocol v3]
测试表/数据:
和代码:
因为node.js驱动程序仅在cassandra 2.1及更高版本中受支持(https://docs.datastax.com/en/developer/nodejs-driver/4.1/faq/#which-cassandra的版本(驱动程序是否支持),我不认为cassandra或驱动程序项目会接受bug请求。你能至少升级到2.1吗?