<commit_before>// Copyright 2014 MongoDB Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <mongocxx/database.hpp>

#include <utility>

#include <bsoncxx/stdx/make_unique.hpp>

#include <mongocxx/client.hpp>
#include <mongocxx/exception/operation.hpp>
#include <mongocxx/private/database.hpp>
#include <mongocxx/private/client.hpp>
#include <mongocxx/private/read_preference.hpp>
#include <mongocxx/private/libbson.hpp>
#include <mongocxx/private/libmongoc.hpp>

namespace mongocxx {
MONGOCXX_INLINE_NAMESPACE_BEGIN

database::database(database&&) noexcept = default;
database& database::operator=(database&&) noexcept = default;

database::~database() = default;

database::database(const class client& client, bsoncxx::stdx::string_view name)
    : _impl(bsoncxx::stdx::make_unique<impl>(
          libmongoc::client_get_database(client._impl->client_t, name.data()), client._impl.get(),
          name.data())) {
}

void* database::implementation() const {
    return _impl->database_t;
}

bsoncxx::stdx::string_view database::name() const {
    return _impl->name;
}

bsoncxx::document::value database::command(bsoncxx::document::view command) {
    libbson::scoped_bson_t command_bson{command};
    libbson::scoped_bson_t reply_bson;
    bson_error_t error;

    auto result = libmongoc::database_command_simple(_impl->database_t, command_bson.bson(), NULL,
                                                     reply_bson.bson(), &error);

    if (!result) throw exception::operation(std::move(reply_bson.steal()));<commit_msg>added missing initialization step in database::command<commit_after>// Copyright 2014 MongoDB Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <mongocxx/database.hpp>

#include <utility>

#include <bsoncxx/stdx/make_unique.hpp>

#include <mongocxx/client.hpp>
#include <mongocxx/exception/operation.hpp>
#include <mongocxx/private/database.hpp>
#include <mongocxx/private/client.hpp>
#include <mongocxx/private/read_preference.hpp>
#include <mongocxx/private/libbson.hpp>
#include <mongocxx/private/libmongoc.hpp>

namespace mongocxx {
MONGOCXX_INLINE_NAMESPACE_BEGIN

database::database(database&&) noexcept = default;
database& database::operator=(database&&) noexcept = default;

database::~database() = default;

database::database(const class client& client, bsoncxx::stdx::string_view name)
    : _impl(bsoncxx::stdx::make_unique<impl>(
          libmongoc::client_get_database(client._impl->client_t, name.data()), client._impl.get(),
          name.data())) {
}

void* database::implementation() const {
    return _impl->database_t;
}

bsoncxx::stdx::string_view database::name() const {
    return _impl->name;
}

bsoncxx::document::value database::command(bsoncxx::document::view command) {
    libbson::scoped_bson_t command_bson{command};
    libbson::scoped_bson_t reply_bson;
    bson_error_t error;

    reply_bson.flag_init();
    auto result = libmongoc::database_command_simple(_impl->database_t, command_bson.bson(), NULL,
                                                     reply_bson.bson(), &error);

    if (!result) throw exception::operation(std::move(reply_bson.steal()));
{'fraction_non_alphanumeric': 0.12467034284344282, 'fraction_numerical': 0.0038360105490290097, 'mean_word_length': 4.489473684210527, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2234879', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1262, 'n_words': 317}