Skip to content

Commit 99dde83

Browse files
added lib
1 parent 2608352 commit 99dde83

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

examples/basic_example/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ target_link_libraries(basic_example PUBLIC
44
yutil
55
library-getopt
66
YDB-CPP-SDK::Table
7+
public-lib-json_value
78
)
89

910
target_sources(basic_example PRIVATE

examples/basic_example/basic_example.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "basic_example.h"
22

33
#include <ydb-cpp-sdk/util/string/cast.h>
4+
#include <ydb-cpp-sdk/json_value/ydb_json_value.h>
45

56
#include <src/util/folder/pathsplit.h>
67

@@ -441,7 +442,10 @@ void SelectSimple(TTableClient client, const std::string& path) {
441442
ThrowOnError(client.RetryOperationSync([path, &resultSet](TSession session) {
442443
return SelectSimpleTransaction(session, path, resultSet);
443444
}));
444-
445+
446+
if (resultSet.has_value()) {
447+
std::cout << FormatResultSetJson(resultSet.value(), EBinaryStringEncoding::Base64);
448+
}
445449
TResultSetParser parser(*resultSet);
446450
if (parser.TryNextRow()) {
447451
std::cout << "> SelectSimple:" << std::endl << "Series"

tests/integration/basic_example_it/basic_example.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "basic_example.h"
22

33
#include <src/util/folder/pathsplit.h>
4+
#include <include/ydb-cpp-sdk/json_value/ydb_json_value.h>
45

56
#include <format>
67

@@ -82,7 +83,7 @@ static void CreateTables(TTableClient client, const std::string& path) {
8283
}
8384

8485
//! Describe existing table.
85-
static std::string DescribeTable(TTableClient client, const std::string& path, const std::string& name) {
86+
static void DescribeTable(TTableClient client, const std::string& path, const std::string& name) {
8687
std::optional<TTableDescription> desc;
8788
std::string result;
8889
ThrowOnError(client.RetryOperationSync([path, name, &desc](TSession session) {
@@ -91,15 +92,13 @@ static std::string DescribeTable(TTableClient client, const std::string& path, c
9192
if (result.IsSuccess()) {
9293
desc = result.GetTableDescription();
9394
}
94-
9595
return result;
9696
}));
9797

98-
result += std::format("> Describe table: {}\n", name);
98+
std::cout << std::format("> Describe table: {}\n", name);
9999
for (auto& column : desc->GetColumns()) {
100-
result += std::format("Column, name: {}, type: {}\n", column.Name, FormatType(column.Type));
100+
std::cout << std::format("Column, name: {}, type: {}\n", column.Name, FormatType(column.Type));
101101
}
102-
return result;
103102
}
104103

105104
///////////////////////////////////////////////////////////////////////////////
@@ -439,7 +438,6 @@ std::string SelectSimple(TTableClient client, const std::string& path) {
439438
ThrowOnError(client.RetryOperationSync([path, &resultSet](TSession session) {
440439
return SelectSimpleTransaction(session, path, resultSet);
441440
}));
442-
443441
TResultSetParser parser(*resultSet);
444442
if (parser.TryNextRow()) {
445443
return std::format("> SelectSimple:\nSeries, Id: {}, Title: {}, Release date: {}\n"
@@ -585,7 +583,7 @@ std::unique_ptr<Response> Run(const TDriver& driver, const std::string& path) {
585583
try {
586584
CreateTables(client, path);
587585

588-
response->result += DescribeTable(client, path, "series");
586+
DescribeTable(client, path, "series");
589587

590588
ThrowOnError(client.RetryOperationSync([path](TSession session) {
591589
return FillTableDataTransaction(session, path);

0 commit comments

Comments
 (0)