Use putBatch only for multiple puts, fix bug in setDatabaseVal (#4800)

This commit is contained in:
JanEbbing 2018-08-06 12:49:07 +01:00 committed by Giorgi Guliashvili
parent ad60c9478c
commit 0cd8283a8a
2 changed files with 4 additions and 4 deletions

View File

@ -256,7 +256,7 @@ Status sendPutBatchDatabaseRequest(const std::string& domain,
Status sendPutDatabaseRequest(const std::string& domain, Status sendPutDatabaseRequest(const std::string& domain,
const DatabaseStringValueList& data) { const DatabaseStringValueList& data) {
const auto& key = data[0].first; const auto& key = data[0].first;
const auto& value = data[1].second; const auto& value = data[0].second;
PluginRequest request = { PluginRequest request = {
{"action", "put"}, {"domain", domain}, {"key", key}, {"value", value}}; {"action", "put"}, {"domain", domain}, {"key", key}, {"value", value}};
@ -328,7 +328,7 @@ Status setDatabaseBatch(const std::string& domain,
// External registries (extensions) do not have databases active. // External registries (extensions) do not have databases active.
// It is not possible to use an extension-based database. // It is not possible to use an extension-based database.
if (RegistryFactory::get().external()) { if (RegistryFactory::get().external()) {
if (data.size() >= 1) { if (data.size() > 1) {
return sendPutBatchDatabaseRequest(domain, data); return sendPutBatchDatabaseRequest(domain, data);
} else { } else {
return sendPutDatabaseRequest(domain, data); return sendPutDatabaseRequest(domain, data);

View File

@ -37,7 +37,7 @@ TEST_F(DatabaseTests, test_set_value_int) {
TEST_F(DatabaseTests, test_set_str_batch) { TEST_F(DatabaseTests, test_set_str_batch) {
DatabaseStringValueList batch = { DatabaseStringValueList batch = {
{"str1", "{}"}, {"str2", "{}"}, {"str3", "{}"}}; {"str1", "{a}"}, {"str2", "{b}"}, {"str3", "{c}"}};
auto s = setDatabaseBatch(kLogs, batch); auto s = setDatabaseBatch(kLogs, batch);
EXPECT_TRUE(s.ok()); EXPECT_TRUE(s.ok());
@ -111,7 +111,7 @@ TEST_F(DatabaseTests, test_get_value_mix1) {
TEST_F(DatabaseTests, test_get_str_batch) { TEST_F(DatabaseTests, test_get_str_batch) {
DatabaseStringValueList batch = { DatabaseStringValueList batch = {
{"str1", "{}"}, {"str2", "{}"}, {"str3", "{}"}}; {"str1", "{a}"}, {"str2", "{b}"}, {"str3", "{c}"}};
auto s = setDatabaseBatch(kLogs, batch); auto s = setDatabaseBatch(kLogs, batch);
EXPECT_TRUE(s.ok()); EXPECT_TRUE(s.ok());