[JCBC-487] com.couchbase.client.protocol.views.Qery key construct Created: 07/Jul/14  Updated: 15/Jul/14  Resolved: 15/Jul/14

Status: Resolved
Project: Couchbase Java Client
Component/s: Views
Affects Version/s: 1.4.1, 1.4.3
Fix Version/s: None
Security Level: Public

Type: Bug Priority: Major
Reporter: reinerRubin Assignee: Michael Nitschinger
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   
Hello.
There is a little bug in query.setKey. When

String login = "0987654321";
Query query = new Query();
query.setKey(login);

query will be with ?key=987654321 not 0987654321.

It's happen in query.quote()
(https://github.com/couchbase/couchbase-java-client/blob/1.4.3/src/main/java/com/couchbase/client/protocol/views/Query.java#L292)


Also in version 1.3.0 in similar situation (key = "0987654321") key will be key=0987654321 and in response
java.util.concurrent.ExecutionException: OperationException: SERVER: bad_request Reason: invalid UTF-8 JSON: {{error,garbage_after_value},\"0987654321\"}

// Excuse my bad English

 Comments   
Comment by Michael Nitschinger [ 07/Jul/14 ]
You should use ComplexKey instead of the string directly.

Try:

query.setKey(ComplexKey.of("0987654321");
Comment by reinerRubin [ 07/Jul/14 ]
>You should use ComplexKey instead of the string directly.
Thanks. It's work.
But I don't sure about setKey(String) behavior.
Comment by Michael Nitschinger [ 15/Jul/14 ]
Yeah, with the string its not so straightforward, thats why we added the complex key. for now please stick to it, it will be easier with 2.0
Comment by reinerRubin [ 15/Jul/14 ]
Ok. Thanks!




Generated at Tue Jul 22 03:48:50 CDT 2014 using JIRA 5.2.4#845-sha1:c9f4cc41abe72fb236945343a1f485c2c844dac9.