Uploaded image for project: 'Couchbase C client library libcouchbase'
  1. Couchbase C client library libcouchbase
  2. CCBC-1421

Allow empty path for sub-document array methods

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 3.2.0
    • None
    • None
    • None
    • 1

    Description

      In testing PYCBC-1083, I have a handful of sub-document and data structure tests failing. It looks to be related to passing an empty path to sub-document array methods (an example below) in the latest LCB (I am testing against master to prep for the 3.2 release). Historically an empty path was allowed. I think there is also a create_path option, so if I need to make sure that is supplied I can make the necessary updates to documentation and the Python client. However, I think LCB might still need some updates.

      Example Python snippet, works w/ LCB 3.1.4, fails w/ master.

      collection.upsert("my_array", [])
      collection.mutate_in("my_array", [SD.array_append("", "some element")])
      # the document my_array is now ["some element"]
      

      LIBCOUCHBASE_API lcb_STATUS lcb_subdocspecs_array_add_last(lcb_SUBDOCSPECS *operations, size_t index, uint32_t flags,
                                                                 const char *path, size_t path_len, const char *value,
                                                                 size_t value_len)
      {
          if (index >= operations->specs().size()) {
              return LCB_ERR_INVALID_ARGUMENT;
          }
          if (path == nullptr || path_len == 0) {
              return LCB_ERR_INVALID_ARGUMENT;
          }
          if (value == nullptr || value_len == 0) {
              return LCB_ERR_INVALID_ARGUMENT;
          }
          auto &spec = operations->specs()[index];
          spec.opcode(subdoc_opcode::array_add_last);
          spec.path(std::string(path, path_len));
          spec.value(std::string(value, value_len));
          spec.options(flags);
          return LCB_SUCCESS;
      }
      

      Attachments

        Issue Links

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

          Activity

            People

              avsej Sergey Avseyev
              jared.casey Jared Casey
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty