diff --git a/include/ydb-cpp-sdk/library/operation_id/operation_id.h b/include/ydb-cpp-sdk/library/operation_id/operation_id.h index 4d29c77a29..8418288129 100644 --- a/include/ydb-cpp-sdk/library/operation_id/operation_id.h +++ b/include/ydb-cpp-sdk/library/operation_id/operation_id.h @@ -35,8 +35,17 @@ class TOperationId { TOperationId(); explicit TOperationId(const std::string& string, bool allowEmpty = false); + + TOperationId(const TOperationId& other); + TOperationId(TOperationId&& other) = default; + + TOperationId& operator=(const TOperationId& other); + TOperationId& operator=(TOperationId&& other) = default; + + ~TOperationId() = default; + EKind GetKind() const; - EKind& GetMutableKind(); + void SetKind(const EKind& kind); const TDataList& GetData() const; TDataList& GetMutableData(); @@ -47,6 +56,7 @@ class TOperationId { private: bool IsValidKind(int kind); + void CopyData(const TOperationId::TDataList& otherData); EKind Kind; TDataList Data; diff --git a/include/ydb-cpp-sdk/library/yql_common/issue/yql_issue.h b/include/ydb-cpp-sdk/library/yql_common/issue/yql_issue.h index abea688129..02b814c65d 100644 --- a/include/ydb-cpp-sdk/library/yql_common/issue/yql_issue.h +++ b/include/ydb-cpp-sdk/library/yql_common/issue/yql_issue.h @@ -112,7 +112,7 @@ class TIssue; using TIssuePtr = TIntrusivePtr; class TIssue: public TThrRefBase { std::vector> Children_; - std::string Message; + TString Message; public: TPosition Position; TPosition EndPosition; @@ -209,7 +209,7 @@ class TIssue: public TThrRefBase { } // Unsafe method. Doesn't call SanitizeNonAscii(Message) - std::string* MutableMessage() { + TString* MutableMessage() { return &Message; } diff --git a/src/library/operation_id/operation_id.cpp b/src/library/operation_id/operation_id.cpp index 146e45b4fe..53638dc742 100644 --- a/src/library/operation_id/operation_id.cpp +++ b/src/library/operation_id/operation_id.cpp @@ -120,12 +120,32 @@ TOperationId::TOperationId(const std::string &string, bool allowEmpty) { } } +TOperationId::TOperationId(const TOperationId& other) { + Kind = other.Kind; + CopyData(other.Data); +} + +TOperationId& TOperationId::operator=(const TOperationId& other) { + Kind = other.Kind; + Data.clear(); + Index.clear(); + CopyData(other.Data); + return *this; +} + +void TOperationId::CopyData(const TOperationId::TDataList& otherData) { + for (const auto& data : otherData) { + Data.push_back(std::make_unique(data->Key, data->Value)); + Index[data->Key].push_back(&Data.back()->Value); + } +} + TOperationId::EKind TOperationId::GetKind() const { return Kind; } -TOperationId::EKind& TOperationId::GetMutableKind() { - return Kind; +void TOperationId::SetKind(const EKind& kind) { + Kind = kind; } const TOperationId::TDataList& TOperationId::GetData() const { diff --git a/tests/unit/library/operation_id/operation_id_ut.cpp b/tests/unit/library/operation_id/operation_id_ut.cpp index 19157ec00f..a7d5c51f99 100644 --- a/tests/unit/library/operation_id/operation_id_ut.cpp +++ b/tests/unit/library/operation_id/operation_id_ut.cpp @@ -18,7 +18,7 @@ Y_UNIT_TEST_SUITE(OperationIdTest) { Y_UNIT_TEST(PreparedQueryIdCompatibleFormatter) { TOperationId opId; - opId.GetMutableKind() = TOperationId::PREPARED_QUERY_ID; + opId.SetKind(TOperationId::PREPARED_QUERY_ID); AddOptionalValue(opId, "id", PreparedQueryId); auto result = opId.ToString(); UNIT_ASSERT_VALUES_EQUAL(FormatPreparedQueryIdCompat(PreparedQueryId), result);