Skip to content

Commit 14baf93

Browse files
committed
Merge branch 'refs/heads/wl13563-vs2019' into wl12755-tls-ciphers
# Conflicts: # cdk/cmake/DepFindProtobuf.cmake
2 parents e006ad4 + 9112341 commit 14baf93

File tree

13 files changed

+122
-21
lines changed

13 files changed

+122
-21
lines changed

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ ENDIF()
5555
#
5656
set(CMAKE_INSTALL_PREFIX "" CACHE PATH "Install location")
5757

58+
#
59+
# Enable grouping targets into folders for IDE tools
60+
#
61+
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
5862

5963

6064
##########################################################################
@@ -193,6 +197,7 @@ add_config_option(BUILD_STATIC BOOLEAN DEFAULT OFF
193197
)
194198

195199
if(BUILD_STATIC)
200+
196201
message("Building static connector library")
197202
set(BUILD_SHARED_LIBS OFF)
198203

@@ -203,6 +208,7 @@ if(BUILD_STATIC)
203208
)
204209

205210
else()
211+
206212
message("Building shared connector library")
207213
set(BUILD_SHARED_LIBS ON)
208214

@@ -309,6 +315,9 @@ endif()
309315

310316
add_subdirectory(cdk)
311317

318+
foreach(T cdk cdk_foundation cdk_mysqlx cdk_proto_mysqlx cdk_parser)
319+
set_target_properties(${T} PROPERTIES FOLDER "CDK")
320+
endforeach()
312321

313322
#
314323
# Unit tests framework
@@ -557,6 +566,7 @@ ENDIF (WITH_TESTS)
557566
add_executable(try EXCLUDE_FROM_ALL try.cc)
558567
target_link_libraries(try connector)
559568

569+
560570
if(WITH_JDBC)
561571

562572
add_executable(try_jdbc EXCLUDE_FROM_ALL try_jdbc.cc)
@@ -649,6 +659,8 @@ add_custom_target(link_test
649659
VERBATIM
650660
)
651661

662+
set_target_properties(link_test PROPERTIES FOLDER "Tests")
663+
652664
add_dependencies(link_test connector)
653665
#if(TARGET connector-merge)
654666
# add_dependencies(link_test connector-merge)

cdk/cmake/DepFindProtobuf.cmake

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,19 @@ set(CONFIG_EXPR
8585
$<$<CONFIG:Static>:Release>$<$<NOT:$<CONFIG:Static>>:$<CONFIG>>
8686
)
8787

88+
set(set_arch)
89+
if(CMAKE_GENERATOR_PLATFORM)
90+
set(set_arch -A ${CMAKE_GENERATOR_PLATFORM})
91+
endif()
92+
8893
set(set_toolset)
8994
if(CMAKE_GENERATOR_TOOLSET)
9095
set(set_toolset -T ${CMAKE_GENERATOR_TOOLSET})
9196
endif()
9297

9398
if(NOT EXISTS "${PB_BINARY_DIR}/exports.cmake")
9499

95-
message("==== Configuring Protobuf build using cmake generator: ${CMAKE_GENERATOR}")
100+
message("==== Configuring Protobuf build using cmake generator: ${CMAKE_GENERATOR} ${set_arch} ${set_toolset}")
96101

97102
file(REMOVE "${PB_BINARY_DIR}/CMakeCache.txt")
98103
file(MAKE_DIRECTORY "${PB_BINARY_DIR}")
@@ -106,7 +111,8 @@ if(NOT EXISTS "${PB_BINARY_DIR}/exports.cmake")
106111
execute_process(
107112
COMMAND ${CMAKE_COMMAND}
108113
-G "${CMAKE_GENERATOR}"
109-
${set_toolset}
114+
${set_arch}
115+
${set_toolset}
110116
${set_build_type}
111117
-DSTATIC_MSVCRT=${STATIC_MSVCRT}
112118
-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}
@@ -256,6 +262,8 @@ add_custom_target(build_protobuf
256262
SOURCES "${build_stamp}"
257263
)
258264

265+
set_target_properties(build_protobuf PROPERTIES FOLDER "Misc")
266+
259267
add_dependencies(Protobuf::pb-full build_protobuf)
260268
add_dependencies(Protobuf::pb-lite build_protobuf)
261269
add_dependencies(Protobuf::protoc build_protobuf)

cdk/cmake/DepFindSSL.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ function(main)
118118
add_library(openssl-applink STATIC "${OPENSSL_INCLUDE_DIR}/openssl/applink.c")
119119
target_link_libraries(SSL::ssl INTERFACE openssl-applink)
120120

121+
set_target_properties(openssl-applink PROPERTIES FOLDER "Misc")
121122
# Remove warnings from openssl applink.c
122123
target_compile_options(openssl-applink PRIVATE /wd4152 /wd4996)
123124

cdk/cmake/headers.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ if(WITH_HEADER_CHECKS)
406406
COMMENT "Header checks"
407407
SOURCES ${all_headers}
408408
)
409+
set_target_properties(Headers PROPERTIES FOLDER "Tests")
409410

410411
#
411412
# Configure the sanity checks project. All CMakeLists.txt files defining the project

cdk/cmake/testing.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ IF(WITH_TESTS)
143143
set_global(test_tests ${test_tests})
144144

145145
add_library(${TEST} OBJECT ${ARGN})
146+
set_target_properties(${TEST} PROPERTIES FOLDER "Tests")
146147

147148
target_include_directories(${TEST} PRIVATE ${test_includes})
148149

@@ -152,6 +153,7 @@ IF(WITH_TESTS)
152153

153154
target_compile_definitions(${TEST} PRIVATE
154155
-D_SCL_SECURE_NO_WARNINGS
156+
-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING
155157
)
156158

157159
target_compile_options(${TEST} PRIVATE
@@ -276,6 +278,7 @@ IF(WITH_TESTS)
276278
${CMAKE_CURRENT_BINARY_DIR}/tests_main.cc
277279
${test_sources}
278280
)
281+
set_target_properties(${target_run_unit_tests} PROPERTIES FOLDER "Tests")
279282

280283
TARGET_LINK_LIBRARIES(${target_run_unit_tests} gtest)
281284

@@ -285,6 +288,11 @@ IF(WITH_TESTS)
285288

286289
if (MSVC)
287290

291+
target_compile_definitions(${target_run_unit_tests} PRIVATE
292+
-D_SCL_SECURE_NO_WARNINGS
293+
-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING
294+
)
295+
288296
target_compile_options(${target_run_unit_tests} PRIVATE
289297
/wd4244
290298
/wd4267
@@ -345,6 +353,8 @@ IF(WITH_TESTS)
345353
SOURCES ${tests_dir}/test_main.in
346354
)
347355

356+
set_target_properties(${cdk_target_prefix}update_test_groups PROPERTIES FOLDER "Tests")
357+
348358
ENDIF()
349359
ENDMACRO(ADD_TEST_TARGET)
350360

cdk/extra/uuid/src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ SET (UUID_SRCS uuid_gen.cc)
4141
ADD_LIBRARY(uuid_gen STATIC ${UUID_SRCS})
4242

4343
SET_TARGET_PROPERTIES(uuid_gen PROPERTIES LINKER_LANGUAGE CXX)
44+
set_target_properties(uuid_gen PROPERTIES FOLDER "Misc")
4445

4546
get_filename_component(INC_DIR "../include" ABSOLUTE)
4647
target_include_directories(uuid_gen PUBLIC ${INC_DIR})

cmake/libutils.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ function(merge_libraries TARGET)
207207

208208
add_library(${TARGET}-deps SHARED EXCLUDE_FROM_ALL "${LIBUTILS_SCRIPT_DIR}/empty.cc")
209209
target_link_libraries(${TARGET}-deps ${ARGN})
210+
set_target_properties(${TARGET}-deps PROPERTIES FOLDER "Misc")
210211

211212
#
212213
# We set RULE_LAUNCH_LINK property of the -deps target to intercept the
@@ -281,6 +282,7 @@ function(merge_libraries TARGET)
281282
#
282283

283284
add_library(${TARGET}-deps SHARED EXCLUDE_FROM_ALL "${LIBUTILS_SCRIPT_DIR}/empty.cc")
285+
set_target_properties(${TARGET}-deps PROPERTIES FOLDER "Misc")
284286
target_link_libraries(${TARGET}-deps ${ARGN})
285287

286288
add_custom_command(TARGET ${TARGET} PRE_BUILD

devapi/crud.cc

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,15 @@ struct Upsert_cmd : public Executable<Result, Upsert_cmd>
146146
};
147147

148148

149+
/*
150+
A helper class used by Collection_detail::add_or_replace_one().
151+
152+
It is a wrapper around CDK expression m_expr that describes a document.
153+
The wrapper forwards this description to a processor, but at the same
154+
time checks if the value of the (top-level) "_id" field equals the value
155+
given in the constructor.
156+
*/
157+
149158
struct Value_expr_check_id
150159
: cdk::Expression
151160
, cdk::Expression::Processor
@@ -157,6 +166,19 @@ struct Value_expr_check_id
157166
Processor *m_prc;
158167
Doc_prc *m_doc_prc;
159168

169+
/*
170+
This class defines m_any_prc member which is used below
171+
to check the value of "_id" field as reported by the
172+
source expression. Before using this class, m_id_prc must be
173+
set to point at the sub-processor that was given for processing
174+
the value of the "_id" field (this is done by key_val() callback in
175+
the main class).
176+
177+
Then all callbacks are forwarded to this sub-processor (or its
178+
sub-processors) and in case of calling scalar str() callback that
179+
gives string value of the "_id" field, the check is done first.
180+
*/
181+
160182
struct Any_processor_check
161183
: cdk::Expression::Processor::Doc_prc::Any_prc
162184
, cdk::Expression::Processor::Doc_prc::Any_prc::Scalar_prc
@@ -165,9 +187,9 @@ struct Value_expr_check_id
165187
Any_prc *m_id_prc;
166188
Scalar_prc *m_scalar_prc;
167189
Value_prc *m_value_prc;
168-
const string& m_id;
190+
const std::string &m_id;
169191

170-
Any_processor_check(const string& id)
192+
Any_processor_check(const std::string& id)
171193
: m_id(id)
172194
{}
173195

@@ -231,6 +253,7 @@ struct Value_expr_check_id
231253
}
232254

233255
// Value processor implementation
256+
234257
void null() override { m_value_prc->null();}
235258

236259
void value(cdk::Type_info type,
@@ -246,6 +269,7 @@ struct Value_expr_check_id
246269
throw mysqlx::Error(R"(Document "_id" and replace id are different!)");
247270
m_value_prc->str(val);
248271
}
272+
249273
void num(int64_t val) override { m_value_prc->num(val); }
250274
void num(uint64_t val) override { m_value_prc->num(val); }
251275
void num(float val) override { m_value_prc->num(val); }
@@ -256,7 +280,7 @@ struct Value_expr_check_id
256280

257281
Any_processor_check m_any_prc;
258282

259-
Value_expr_check_id(mysqlx::Value_expr &expr, bool is_expr, const string& id)
283+
Value_expr_check_id(mysqlx::Value_expr &expr, bool is_expr, const std::string& id)
260284
: m_expr(expr)
261285
, m_is_expr(is_expr)
262286
, m_any_prc(id)
@@ -324,7 +348,14 @@ Collection_detail::add_or_replace_one(
324348
const mysqlx::string &id, mysqlx::Value &&doc, bool replace
325349
)
326350
{
351+
/*
352+
This is implemented by executing Replace_cmd or Upsert_command
353+
which internally use Op_collection_replace or Op_collection_upsert
354+
to perform relevant operation on the server.
355+
*/
356+
327357
Object_ref coll(get_schema().m_name, m_name);
358+
std::string id_str(id);
328359

329360

330361
if (!Value::Access::is_expr(doc) &&
@@ -333,13 +364,29 @@ Collection_detail::add_or_replace_one(
333364
doc = DbDoc(doc.get<string>());
334365
}
335366

367+
/*
368+
expr is a CDK expression object which describes the document
369+
to be added.
370+
*/
371+
336372
Value_expr expr(doc, parser::Parser_mode::DOCUMENT);
337373

338374
if (replace)
339375
{
340-
Value_expr_check_id check_id(expr, Value::Access::is_expr(doc), id);
376+
/*
377+
Replace_cmd executes Op_collection_replace which picks a document
378+
with the given id and replaes it with the document given as the last
379+
argument.
380+
381+
The document expression is wrapped in Value_expr_check_id to check
382+
if the "_id" field (if present) stores the correct document id
383+
and throws error if it is not the case (otherwise Replace_cmd
384+
would modify the "_id" field to match the given id).
385+
*/
386+
387+
Value_expr_check_id check_id(expr, Value::Access::is_expr(doc), id_str);
341388

342-
Replace_cmd cmd(m_sess, coll, std::string(id), check_id);
389+
Replace_cmd cmd(m_sess, coll, id_str, check_id);
343390
return cmd.execute();
344391
}
345392
else

devapi/tests/crud-t.cc

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2469,22 +2469,30 @@ TEST_F(Crud, single_document)
24692469
Schema sch = getSchema("test");
24702470
Collection coll = sch.createCollection("c1", true);
24712471

2472+
cout << "Adding documents..." << endl;
2473+
24722474
coll.remove("true").execute();
24732475

2474-
coll.add(R"({"_id":"id1", "name":"foo", "age": 1 })" )
2475-
.add(R"({"_id":"id2", "name":"bar", "age": 2 })" )
2476-
.add(R"({"_id":"id3", "name":"baz", "age": 3 })" )
2477-
.execute();
2476+
coll.add(R"({"_id":"id1", "name":"foo", "age": 1 })")
2477+
.add(R"({"_id":"id2", "name":"bar", "age": 2 })")
2478+
.add(R"({"_id":"id3", "name":"baz", "age": 3 })")
2479+
.execute();
2480+
2481+
cout << "getOne()" << endl;
24782482

24792483
EXPECT_EQ(string("foo"), coll.getOne("id1")["name"].get<string>());
24802484
EXPECT_EQ(string("bar"), coll.getOne("id2")["name"].get<string>());
24812485
EXPECT_TRUE(coll.getOne("idZ").isNull());
24822486

2487+
cout << "removeOne()" << endl;
2488+
24832489
EXPECT_EQ(1, coll.removeOne("id1").getAffectedItemsCount());
24842490
EXPECT_EQ(0, coll.removeOne("id1").getAffectedItemsCount());
24852491

24862492
EXPECT_TRUE(coll.getOne("id1").isNull());
24872493

2494+
cout << "replaceOne()" << endl;
2495+
24882496
// Replace existing document
24892497
EXPECT_EQ(1, coll.replaceOne(
24902498
"id3",
@@ -2493,6 +2501,8 @@ TEST_F(Crud, single_document)
24932501
EXPECT_EQ(string("qux"), coll.getOne("id3")["name"].get<string>());
24942502
EXPECT_EQ(4, coll.getOne("id3")["age"].get<int>());
24952503

2504+
cout << "replaceOne(): change id" << endl;
2505+
24962506
// Setting a different _id on document should throw error
24972507
// Document passed as string
24982508
EXPECT_THROW(coll.replaceOne("id3", "{\"_id\": \"id4\", \"name\": \"baz\" }"),
@@ -2508,13 +2518,20 @@ TEST_F(Crud, single_document)
25082518
// Document passed as DbDoc
25092519
EXPECT_THROW(coll.replaceOne("id3", DbDoc("{\"_id\": \"id4\", \"name\": \"baz\" }")),
25102520
Error);
2521+
2522+
cout << "getOne(): array" << endl;
2523+
25112524
EXPECT_EQ(string("qux"), coll.getOne("id3")["name"].get<string>());
25122525
EXPECT_EQ(string("id3"), coll.getOne("id3")["_id"].get<string>());
25132526

2527+
cout << "replaceOne(): non-existing" << endl;
2528+
25142529
// should affect none
25152530
EXPECT_EQ(0,
25162531
coll.replaceOne("id4", expr(R"({"name": "baz" })"))
25172532
.getAffectedItemsCount());
2533+
2534+
cout << "Done!" << endl;
25182535
}
25192536

25202537

devapi/tests/session-t.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1846,7 +1846,8 @@ TEST_F(Sess, pool_opts)
18461846

18471847

18481848
std::stringstream uri;
1849-
uri << "mysqlx://" << get_user()<< "@localhost:"<< get_port() <<"/test";
1849+
uri << "mysqlx://" << (get_user() ? get_user() : "user")
1850+
<< "@localhost:" << get_port() <<"/test";
18501851

18511852
ClientSettings working_settings(uri.str(),
18521853
R"( { "pooling": {

devapi/tests/types-t.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,8 @@ const CollationInfo* get_collation(unsigned id)
515515

516516
TEST_F(Types, collations)
517517
{
518+
SKIP_IF_NO_XPLUGIN;
519+
518520
using col_data = std::pair<unsigned, string>;
519521
std::vector<col_data> unknown;
520522

0 commit comments

Comments
 (0)