Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-592

database:command returns an empty response

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 0.2.0
    • Affects Version/s: None
    • Component/s: API
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      This returns an empty document:

      #include <mongocxx/client.hpp>
      #include <bsoncxx/builder/stream/document.hpp>
      #include <bsoncxx/json.hpp>
      
      #include <iostream>
      
      using bsoncxx::builder::stream::document;
      
      int main(int, char**) {
          mongocxx::client conn{};
          document command;
          command << "buildInfo" << 1;
          auto db = conn["test"];
          auto result = db.command(command.view());
          std::cout << "buildInfo response: " << bsoncxx::to_json(result.view()) << std::endl;
          return 0;
          
      }
      

      (actually it crashes on exception, but that is due to CXX-587)

      I tracked this down to missing initialization in scoped_bson_t reply object.

      Patch in https://github.com/mongodb/mongo-cxx-driver/pull/284

            Assignee:
            adam.midvidy Adam Midvidy (Inactive)
            Reporter:
            yhager Yuval Hager
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: