Uploaded image for project: 'Spymemcached Java Client'
  1. Spymemcached Java Client
  2. SPY-62

need more than setKey(String) or setRange(String, String) to be able to express queires

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.8.0-dp2
    • Fix Version/s: None
    • Component/s: None
    • Security Level: Public
    • Labels:
      None

      Description

      Views can have integer datatypes. I do see that we check for that in StringUtils, but it's a bit of an odd API at the moment to have to quote your own string if you want your string as a string and not numbers. Perhaps we need to think this through a bit further.

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

        Activity

        Hide
        daschl Michael Nitschinger added a comment -

        Handled in the JCBC library through the ComplexKey class.

        Show
        daschl Michael Nitschinger added a comment - Handled in the JCBC library through the ComplexKey class.
        Hide
        daschl Michael Nitschinger added a comment -

        There have been some recent changes with the ComplexKey additions in the couchbase client, I guess this can be closed soon since most of this has been fixed already.

        Show
        daschl Michael Nitschinger added a comment - There have been some recent changes with the ComplexKey additions in the couchbase client, I guess this can be closed soon since most of this has been fixed already.
        Hide
        drakmir Alan Wood added a comment - - edited

        Changing this function in Query.java worked for my case (if I also pre-quote the string being passed into Query.setKey from my main code).
        Not the most elegant fix, but it may be handy for someone else running into a similar issue until a more official fix is in place.

        private String getArg(String key, Object value) {
        String valStr = value.toString();
        // Special case
        if (key.equals(STARTKEYDOCID))

        { return key + "=" + valStr; } else if (value instanceof Stale) { return key + "=" + valStr; }

        else if (StringUtils.isJsonObject(valStr))

        { return key + "=" + valStr; // Don't requote a pre-quoted string }

        else if ((valStr.length() >= 2) && (valStr.charAt(0) == '\"') && (valStr.charAt(valStr.length() - 1) == '\"'))

        { return key + "=" + valStr; }

        else

        { return key + "=\"" + valStr + "\""; }

        }

        Show
        drakmir Alan Wood added a comment - - edited Changing this function in Query.java worked for my case (if I also pre-quote the string being passed into Query.setKey from my main code). Not the most elegant fix, but it may be handy for someone else running into a similar issue until a more official fix is in place. private String getArg(String key, Object value) { String valStr = value.toString(); // Special case if (key.equals(STARTKEYDOCID)) { return key + "=" + valStr; } else if (value instanceof Stale) { return key + "=" + valStr; } else if (StringUtils.isJsonObject(valStr)) { return key + "=" + valStr; // Don't requote a pre-quoted string } else if ((valStr.length() >= 2) && (valStr.charAt(0) == '\"') && (valStr.charAt(valStr.length() - 1) == '\"')) { return key + "=" + valStr; } else { return key + "=\"" + valStr + "\""; } }
        Hide
        drakmir Alan Wood added a comment - - edited

        Related to this:

        I have a key that looks like an integer in some cases (it is just a sequence of characters). When the string based key looks like a integer, this code in Query.java treats it as one and doesn't quote it:

        // Special case
        if (key.equals(STARTKEYDOCID))

        { return key + "=" + value; }

        else if (value instanceof Stale)

        { return key + "=" + ((Stale) value).toString(); }

        else if (StringUtils.isJsonObject(value.toString()))

        { return key + "=" + value.toString(); }

        else

        { return key + "=\"" + value + "\""; }

        For some reason a string like 100 will trigger the StringUtils.isJsonObject to return true.
        Passing in a quoted string like "100" ends up NOT firing that same code (even though it is a valid JSON object) which ends up double quoting the string.

        As such, for keys that look like "integers", the current Query code fails to return any documents since it is either passing through the literal 100 or the literal ""100"".

        Show
        drakmir Alan Wood added a comment - - edited Related to this: I have a key that looks like an integer in some cases (it is just a sequence of characters). When the string based key looks like a integer, this code in Query.java treats it as one and doesn't quote it: // Special case if (key.equals(STARTKEYDOCID)) { return key + "=" + value; } else if (value instanceof Stale) { return key + "=" + ((Stale) value).toString(); } else if (StringUtils.isJsonObject(value.toString())) { return key + "=" + value.toString(); } else { return key + "=\"" + value + "\""; } For some reason a string like 100 will trigger the StringUtils.isJsonObject to return true. Passing in a quoted string like "100" ends up NOT firing that same code (even though it is a valid JSON object) which ends up double quoting the string. As such, for keys that look like "integers", the current Query code fails to return any documents since it is either passing through the literal 100 or the literal ""100"".

          People

          • Assignee:
            daschl Michael Nitschinger
            Reporter:
            ingenthr Matt Ingenthron
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Gerrit Reviews

              There are no open Gerrit changes