Parameterized queries not working for big numbers

When we use big numeric values as part of a parameterized query, they do not return the results. In the example below, it returns no results when it should return some in our environment. Queries work fine from the Couchbase Query UI (of course there is no parameterized queries).

        long accountId = 800390432;
        String prefix = "PREFIX";
        String query = "SELECT id from data1 where split(meta().id, \"::\")[0]=$env and accountId=$accountId"

        Map<String, Object> params = new HashMap<>();
            params.put("accountId", accountId);
            params.put("env", env);

        N1qlParams n1qlParams =
        ParameterizedN1qlQuery parameterized = N1qlQuery.parameterized(query, convert(params), n1qlParams);
        N1qlQueryResult result = sourceBucket.query(parameterized, 10000, TimeUnit.MILLISECONDS);

Performing the above query as-is returns no results.

Performing the above query by replacing accountId directly in the query works fine (returns 5 results). Also, I’m told that smaller numeric values work fine as well. The parameterization of the env works fine both ways.

We’re using Couchbase 4.5.1 and Java client 2.5.1.

@unhuman thats interesting. To figure out if its a client or server issue an for further triaging the following makes sense I think.

  • can you try running those queries from cbq? it provides parameter options via \SET I think so you should be able to run it with and without params.

If the issue happens in cbq as well its very likely a server bug, if it works fine there we need to go look further into the client. If it works with cbq it would be great if you can enable trace logging and post the snippet of write and read for that request here so we can see how the client encodes the requests on the wire.


Yep, happens with cbq with /SET parameter. Works fine inline. Our theory here is that Couchbase uses small int for numeric parameters

Did you tried with 4.6.3

@vsr1 No. I’ve used 4.5.1 and 5.0.

Are u able to reproduce issue with 5.0.0

@vsr1 I’m not sure what’s going on, but today in cbq it works in both 4.5.1 and 5.0. I’m going to have to go back and start over.