Skip to content
Snippets Groups Projects
Verified Commit 75a171cd authored by Timm Fitschen's avatar Timm Fitschen
Browse files

Merge branch 'f-update' into f-query

parents 0628b182 0d3ce44a
No related branches found
No related tags found
1 merge request!7ENH: Support FIND and COUNT queries
Pipeline #11513 passed
Pipeline: caosdb-cppinttest

#11525

    ......@@ -31,7 +31,6 @@
    #include "caosdb/transaction_status.h" // for TransactionStatus
    #include "caosdb/status_code.h" // for StatusCode
    #include "google/protobuf/util/json_util.h" // for MessageToJsonString, Jso...
    #include <cstddef> // for size_t
    #include <iterator>
    // IWYU pragma: no_include <ext/alloc_traits.h>
    #include <memory> // for shared_ptr, unique_ptr
    ......@@ -180,7 +179,7 @@ class ResultSet {
    public:
    virtual ~ResultSet() = default;
    [[nodiscard]] virtual auto Size() const noexcept -> size_t = 0;
    [[nodiscard]] virtual auto Size() const noexcept -> int = 0;
    [[nodiscard]] virtual auto At(const int index) const -> const Entity & = 0;
    auto begin() const -> iterator;
    auto end() const -> iterator;
    ......@@ -188,14 +187,14 @@ public:
    private:
    class iterator : public std::iterator<std::output_iterator_tag, Entity> {
    public:
    explicit iterator(const ResultSet *result_set, size_t index = 0);
    explicit iterator(const ResultSet *result_set, int index = 0);
    auto operator*() const -> const Entity &;
    auto operator++() -> iterator &;
    auto operator++(int) -> iterator;
    auto operator!=(const iterator &rhs) const -> bool;
    private:
    size_t current_index = 0;
    int current_index = 0;
    const ResultSet *result_set;
    };
    };
    ......@@ -210,7 +209,7 @@ class MultiResultSet : public ResultSet {
    public:
    ~MultiResultSet() = default;
    explicit MultiResultSet(MultiTransactionResponse *response);
    [[nodiscard]] inline auto Size() const noexcept -> size_t override {
    [[nodiscard]] inline auto Size() const noexcept -> int override {
    return this->entities.size();
    }
    [[nodiscard]] inline auto At(const int index) const
    ......@@ -234,9 +233,7 @@ public:
    explicit inline UniqueResult(IdResponse *idResponse)
    : entity(new Entity(idResponse)){};
    [[nodiscard]] auto GetEntity() const -> const Entity &;
    [[nodiscard]] inline auto Size() const noexcept -> size_t override {
    return 1;
    }
    [[nodiscard]] inline auto Size() const noexcept -> int override { return 1; }
    [[nodiscard]] inline auto At(const int index) const
    -> const Entity & override {
    if (index != 0) {
    ......
    ......@@ -75,7 +75,8 @@ auto get_status_description(int code) -> const std::string & {
    "The Transaction has a transaction type which does not allow the "
    "attempted action."},
    {StatusCode::ORIGINAL_ENTITY_MISSING_ID,
    "The attempt to update this entity failed because this entity does have "
    "The attempt to update this entity failed because this entity does not "
    "have "
    "an id. This is the case when you did not retrieve it before applying any "
    "changes and instantiated the Entity class explicitely."},
    {StatusCode::UNSUPPORTED_FEATURE,
    ......@@ -100,14 +101,11 @@ using grpc::ClientAsyncResponseReader;
    using ProtoEntity = caosdb::entity::v1alpha1::Entity;
    using grpc::CompletionQueue;
    ResultSet::iterator::iterator(const ResultSet *result_set_param, size_t index)
    ResultSet::iterator::iterator(const ResultSet *result_set_param, int index)
    : current_index(index), result_set(result_set_param) {}
    auto ResultSet::iterator::operator*() const -> const Entity & {
    // TODO(tf) clang warns about a bugprone conversion from unsigned
    // size_t to signed int, i.e., the `index` of ResultSet::At. Should
    // we make this unsigned as well?
    return this->result_set->At(current_index); // NOLINT
    return this->result_set->At(current_index);
    }
    auto ResultSet::iterator::operator++() -> ResultSet::iterator & {
    ......
    ......@@ -30,9 +30,7 @@
    #include "gtest/gtest-message.h" // for Message
    #include "gtest/gtest-test-part.h" // for TestPartResult, Sui...
    #include "gtest/gtest_pred_impl.h" // for Test, EXPECT_EQ
    #include <iostream> // for endl, basic_ostream
    #include <memory> // for allocator, shared_ptr
    #include <string> // for operator<<
    namespace caosdb::entity {
    using caosdb::entity::v1alpha1::IdResponse;
    ......@@ -187,7 +185,6 @@ TEST(test_entity, test_insert_with_parent) {
    transaction.InsertEntity(&entity);
    std::cout << entity.ToString() << std::endl;
    EXPECT_EQ(entity.GetName(), "entity_name");
    EXPECT_EQ(entity.GetParents().Size(), 1);
    auto inserted_parent = entity.GetParents().At(0);
    ......@@ -251,18 +248,14 @@ TEST(test_entity, test_from_id_response) {
    info->set_description("info_desc");
    info->set_code(MessageCode::UNSPECIFIED);
    std::cout << entity.ToString() << std::endl;
    Entity other_ent(&idr_warnings_and_infos);
    std::cout << entity.ToString() << std::endl;
    EXPECT_EQ(other_ent.GetId(), "other_entity_id");
    std::cout << entity.ToString() << std::endl;
    EXPECT_EQ(other_ent.GetWarnings().Size(), 1);
    EXPECT_TRUE(other_ent.HasWarnings());
    EXPECT_EQ(other_ent.GetWarnings().At(0).GetDescription(), "warning_desc");
    EXPECT_EQ(other_ent.GetWarnings().At(0).GetCode(),
    MessageCode::ENTITY_HAS_NO_PROPERTIES);
    std::cout << entity.ToString() << std::endl;
    EXPECT_EQ(other_ent.GetInfos().Size(), 1);
    EXPECT_EQ(other_ent.GetInfos().At(0).GetDescription(), "info_desc");
    EXPECT_EQ(other_ent.GetInfos().At(0).GetCode(), MessageCode::UNSPECIFIED);
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment