Reputation: 19695
Using Couchbase Java DSL, a query using "fish/piraña"
gives a parse-error, but with "fish/piranha"
, there is no parse-error.
I had thought that the x()
method would correctly wrap the non-ASCII Unicode string.
Using N1ql directly, this does work with any field name (except blank) or field value:
parameterized("SELECT * from
" + bucket.name() + "WHERE
" + fieldName + "= $v", placeholders))
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);
Upvotes: 2
Views: 342
Reputation: 2460
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));
I'm still trying to understand the behavior via SDK, I will update this answer as soon as I find the issue.
Upvotes: 2
Reputation: 7414
Json strings can have unicode characters.
insert into default values ("f1",{"name":"fish/pira\u00f1a"});
select * from default where name = "fish/pira\u00f1a";
"results": [
{
"default": {
"name": "fish/piraña"
}
}
]
Collation (ORDER BY, indexing, ....) and data types comparison are based on byte comparison not based on unicode character. If unicode character is single/fixed byte it will work but if the data is variable multi-bytes may not work because comparison is based on byte comparison.
Upvotes: 0
Reputation: 14097
Documentation says it supports unicode.
https://docs.couchbase.com/server/6.0/n1ql/n1ql-language-reference/literals.html
Strings can be either Unicode characters or escaped characters.
Upvotes: 0