Set floating point key with couchbase-client-1.1.0.jar
I am trying to perform a query to a view I created for the beer-sample with the abv values. When I try to set the value to a floating point number (5.2f) using ComplexKey.of(5.2f) the query created is not ?key=5.2 as expected but ?key=%225.2%22.
The reason is the function Query.prepareValue that throws a NumberFormatException when it fails to parse my value as a Long.
My question is why does it try to parse the value as a Long exclusively and does not attempt to parse it as a float.
Thank you,
Panagiotis
Thank you Michael for the reply,
yes, in fact I could work with doubles but I think that it doesn't work with doubles either.
I tried this
query.setKey(ComplexKey.of(Double.valueOf(5.2)));
and again in Query.prepareValue() a NumberFormatException is thrown when it attempts to parse it as a Long. Am I missing something?
Thanks again,
Panagiotis
Oh, I'm sorry, yes I meant Longs (you can try the L literal).
I'm going to fix it up for floats and doubles as well. This shouldn't be a large change, so expect it to be in 1.1.1
Thanks!
Hi panagiotis,
you're perfectly right, it doesn't work with floats currently - only with doubles. Can you use doubles in the meantime? I'll open an enhancement ticket and make sure it will be in there for the 1.1.1 bugfix release.
Thanks,
Michael