在Couchbase Java查询DSL中,如何过滤非ASCII的字段值? [英] In Couchbase Java Query DSL, how do I filter for field-values that are not ASCII?
问题描述
使用Couchbase Java DSL,使用"fish/piraña"
的查询会产生解析错误,但是使用"fish/piranha"
时不会出现解析错误.
Using Couchbase Java DSL, a query using "fish/piraña"
gives a parse-error, but with "fish/piranha"
, there is no parse-error.
我以为 x()
方法可以正确包装非ASCII Unicode字符串.
I had thought that the x()
method would correctly wrap the non-ASCII Unicode string.
直接使用N1ql,它适用于任何字段名称(空白除外)或字段值:
Using N1ql directly, this does work with any field name (except blank) or field value:
已参数化("SELECT * from
" + bucket.name()+" WHERE
" + fieldName +" = $ v",占位符))
parameterized("SELECT * from
" + bucket.name() + "WHERE
" + fieldName + "= $v", placeholders))
如何使用Java查询DSL完成此操作?
How can this be done using the Java Query DSL?
String species "fish/pira\u00f1a" ;
Expression expForType = x("species").eq(x(species));
OffsetPath statement = select("*").from(i(bucket.name())).where(expForType);
N1qlQuery q = N1qlQuery.simple(statement);
N1qlQueryResult result = bucket.query(q);
推荐答案
因此,它通过N1QL起作用:
So, it works via N1QL:
N1qlParams params = N1qlParams.build().consistency(ScanConsistency.REQUEST_PLUS).adhoc(true);
ParameterizedN1qlQuery query = N1qlQuery.parameterized("Select * from `quicktask` where species = 'fish/pira\u00f1a' ", JsonObject.create(), params);
System.out.println(quickProcessHistoryRepository.getCouchbaseOperations().getCouchbaseBucket().query(query));
我仍在尝试通过SDK理解行为,一旦发现问题,我将立即更新此答案.
I'm still trying to understand the behavior via SDK, I will update this answer as soon as I find the issue.
这篇关于在Couchbase Java查询DSL中,如何过滤非ASCII的字段值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!