Uploaded image for project: 'Couchbase Java Client'
  1. Couchbase Java Client
  2. JCBC-41

incorrect conversion from string to number in json attribute

    XMLWordPrintable

Details

    • New Feature
    • Resolution: Fixed
    • Major
    • 1.1-dp4
    • 1.1dp
    • Core
    • Security Level: Public
    • None
    • Java 1.1 client
      CB dp4

    Description

      zendesk ticket from customer below - is there existing functionality for this and it is simply not documented?

      The method Query.setKey( String ) converts strings consisting of digits into numbers instead of keeping the format a string. This can be seen by inspecting the Query object after running setKey( "300" ) (or any other all digit string). The internal association is ?key=300. For example, setKey( "Hey" ) yields ?key="Hey".

      The issue here is that we have data stored in JSON documents where the data portion is treated as a string, but it is all digits. So, a query for setKey( "300" ) fails to match fields that contain "300", because the query is ultimately if ( 300 == "300" ).

      There should be two versions of setKey(), one for strings and one for number types.

      I was unable to find any documentation regarding this particular case, so I assumed it is not an expected issue.

      The problem is inside of the Query class. In getArg(), the check for isJsonObject() returns true for stringified numbers, and the resulting key/value does not contain quotes. The result now is

      ?key=300

      We want the output of the query object to be

      ?key="300"

      or

      ?key=300

      based on the input type (String or number). As of now, it makes that determination for us, which is incorrect.

      which is impossible given the current implementation.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            daschl Michael Nitschinger
            alex Alex Ma [X] (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty