From a55efac890e5c23a1cc46ce9c0af91750b0df156 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Sun, 27 Aug 2023 16:16:23 +0200 Subject: [PATCH] Sqlite: Extent Statement::values for other container You can now use QList and QVarLenghtArray for values. The later is quite interesting because it is not allocating for a provided capacity. So you can now write: statement.valuesWithTransaction>(); And in almost all case no expensive memory is allocated. With the help of NRVO there should be no copy too. That is very useful for temporary values which are transformed into a different type. The capacity changed to an template parameter too: statement.valuesWithTransaction(); That is more clear than before: statement.valuesWithTransaction(1024); Change-Id: I6d8d10ed9db0cc37f0579353a416e36e23c30415 Reviewed-by: Tim Jenssen --- src/libs/sqlite/sqlitebasestatement.h | 35 +++++++++-- src/libs/sqlite/sqlitereadstatement.h | 6 +- src/libs/sqlite/sqlitereadwritestatement.h | 8 ++- src/libs/sqlite/sqlitesessions.cpp | 6 +- .../projectstorage/projectstorage.h | 62 ++++++++++--------- .../projectstorage/projectstorageinterface.h | 6 +- tests/unit/tests/mocks/projectstoragemock.h | 4 +- .../projectstorage/projectstorage-test.cpp | 4 ++ .../sqlite/sqlitealgorithms-test.cpp | 2 +- .../unittests/sqlite/sqlitedatabase-test.cpp | 2 +- .../unittests/sqlite/sqlitesessions-test.cpp | 5 +- .../unittests/sqlite/sqlitestatement-test.cpp | 48 +++++++------- 12 files changed, 114 insertions(+), 74 deletions(-) diff --git a/src/libs/sqlite/sqlitebasestatement.h b/src/libs/sqlite/sqlitebasestatement.h index 54d08260b7c..fd57b4f8f1c 100644 --- a/src/libs/sqlite/sqlitebasestatement.h +++ b/src/libs/sqlite/sqlitebasestatement.h @@ -23,6 +23,7 @@ #include #include #include +#include using std::int64_t; @@ -172,12 +173,28 @@ public: BaseStatement::next(); } - template - auto values(std::size_t reserveSize, const QueryTypes &...queryValues) + template + struct is_container : std::false_type + {}; + template + struct is_container> : std::true_type + {}; + template + struct is_container> : std::true_type + {}; + template + struct is_container> : std::true_type + {}; + + template::value>, + typename... QueryTypes> + auto values(const QueryTypes &...queryValues) { Resetter resetter{this}; - std::vector resultValues; - resultValues.reserve(std::max(reserveSize, m_maximumResultCount)); + Container resultValues; + resultValues.reserve(std::max(capacity, m_maximumResultCount)); bindValues(queryValues...); @@ -189,6 +206,16 @@ public: return resultValues; } + template typename Container = std::vector, + typename = std::enable_if_t::value>, + typename... QueryTypes> + auto values(const QueryTypes &...queryValues) + { + return values, capacity>(queryValues...); + } + template auto value(const QueryTypes &...queryValues) { diff --git a/src/libs/sqlite/sqlitereadstatement.h b/src/libs/sqlite/sqlitereadstatement.h index 3df47efc741..4f8091598b0 100644 --- a/src/libs/sqlite/sqlitereadstatement.h +++ b/src/libs/sqlite/sqlitereadstatement.h @@ -47,11 +47,11 @@ public: }); } - template - auto valuesWithTransaction(std::size_t reserveSize, const QueryTypes &...queryValues) + template + auto valuesWithTransaction(const QueryTypes &...queryValues) { return withDeferredTransaction(Base::database(), [&] { - return Base::template values(reserveSize, queryValues...); + return Base::template values(queryValues...); }); } diff --git a/src/libs/sqlite/sqlitereadwritestatement.h b/src/libs/sqlite/sqlitereadwritestatement.h index 08f1aeda04c..2b3e6c32477 100644 --- a/src/libs/sqlite/sqlitereadwritestatement.h +++ b/src/libs/sqlite/sqlitereadwritestatement.h @@ -47,11 +47,13 @@ public: }); } - template - auto valuesWithTransaction(std::size_t reserveSize, const QueryTypes &...queryValues) + template + auto valuesWithTransaction(const QueryTypes &...queryValues) { return withImmediateTransaction(Base::database(), [&] { - return Base::template values(reserveSize, queryValues...); + return Base::template values(queryValues...); }); } diff --git a/src/libs/sqlite/sqlitesessions.cpp b/src/libs/sqlite/sqlitesessions.cpp index 96119cd20fb..fd81b17edee 100644 --- a/src/libs/sqlite/sqlitesessions.cpp +++ b/src/libs/sqlite/sqlitesessions.cpp @@ -110,7 +110,7 @@ void Sessions::revert() " ORDER BY id DESC"}), database}; - auto changeSets = selectChangeSets.values(1024); + auto changeSets = selectChangeSets.values(); for (auto &changeSet : changeSets) { int resultCode = sqlite3changeset_apply_v2(database.backend().sqliteDatabaseHandle(), @@ -134,7 +134,7 @@ void Sessions::apply() " ORDER BY id"}), database}; - auto changeSets = selectChangeSets.values(1024); + auto changeSets = selectChangeSets.values(); for (auto &changeSet : changeSets) { int resultCode = sqlite3changeset_apply_v2(database.backend().sqliteDatabaseHandle(), @@ -170,7 +170,7 @@ SessionChangeSets Sessions::changeSets() const " ORDER BY id DESC"}), database}; - return selectChangeSets.values(1024); + return selectChangeSets.values(); } void Sessions::Deleter::operator()(sqlite3_session *session) diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h b/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h index f3977ac8c41..b1190874f75 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h +++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h @@ -160,14 +160,14 @@ public: Storage::Info::ExportedTypeNames exportedTypeNames(TypeId typeId) const override { return selectExportedTypesByTypeIdStatement - .template valuesWithTransaction(4, typeId); + .template valuesWithTransaction(typeId); } Storage::Info::ExportedTypeNames exportedTypeNames(TypeId typeId, SourceId sourceId) const override { return selectExportedTypesByTypeIdAndSourceIdStatement - .template valuesWithTransaction(4, typeId, sourceId); + .template valuesWithTransaction(typeId, sourceId); } ImportId importId(const Storage::Import &import) const override @@ -197,16 +197,16 @@ public: }); } - PropertyDeclarationIds propertyDeclarationIds(TypeId typeId) const override + QVarLengthArray propertyDeclarationIds(TypeId typeId) const override { return selectPropertyDeclarationIdsForTypeStatement - .template valuesWithTransaction(32, typeId); + .template valuesWithTransaction>(typeId); } - PropertyDeclarationIds localPropertyDeclarationIds(TypeId typeId) const override + QVarLengthArray localPropertyDeclarationIds(TypeId typeId) const override { return selectLocalPropertyDeclarationIdsForTypeStatement - .template valuesWithTransaction(16, typeId); + .template valuesWithTransaction>(typeId); } PropertyDeclarationId propertyDeclarationId(TypeId typeId, @@ -240,13 +240,13 @@ public: std::vector signalDeclarationNames(TypeId typeId) const override { return selectSignalDeclarationNamesForTypeStatement - .template valuesWithTransaction(32, typeId); + .template valuesWithTransaction(typeId); } std::vector functionDeclarationNames(TypeId typeId) const override { return selectFuncionDeclarationNamesForTypeStatement - .template valuesWithTransaction(32, typeId); + .template valuesWithTransaction(typeId); } std::optional propertyName(PropertyDeclarationId propertyDeclarationId) const override @@ -280,14 +280,14 @@ public: TypeIds prototypeIds(TypeId type) const override { - return selectPrototypeIdsForTypeIdInOrderStatement.template valuesWithTransaction(16, - type); + return selectPrototypeIdsForTypeIdInOrderStatement.template valuesWithTransaction( + type); } TypeIds prototypeAndSelfIds(TypeId type) const override { return selectPrototypeAndSelfIdsForTypeIdInOrderStatement - .template valuesWithTransaction(16, type); + .template valuesWithTransaction(type); } template @@ -383,7 +383,7 @@ public: Storage::Synchronization::Types fetchTypes() { return Sqlite::withDeferredTransaction(database, [&] { - auto types = selectTypesStatement.template values(64); + auto types = selectTypesStatement.template values(); for (Storage::Synchronization::Type &type : types) { type.exportedTypes = fetchExportedTypes(type.typeId); @@ -441,8 +441,8 @@ public: auto fetchAllSourceContexts() const { - return selectAllSourceContextsStatement.template valuesWithTransaction( - 128); + return selectAllSourceContextsStatement + .template valuesWithTransaction(); } SourceId fetchSourceId(SourceContextId sourceContextId, Utils::SmallStringView sourceName) @@ -484,7 +484,7 @@ public: auto fetchAllSources() const { - return selectAllSourcesStatement.template valuesWithTransaction(1024); + return selectAllSourcesStatement.template valuesWithTransaction(); } SourceId fetchSourceIdUnguarded(SourceContextId sourceContextId, Utils::SmallStringView sourceName) @@ -517,14 +517,15 @@ public: Storage::Synchronization::ProjectDatas fetchProjectDatas(SourceId projectSourceId) const override { return selectProjectDatasForSourceIdStatement - .template valuesWithTransaction(64, - projectSourceId); + .template valuesWithTransaction( + projectSourceId); } Storage::Synchronization::ProjectDatas fetchProjectDatas(const SourceIds &projectSourceIds) const { - return selectProjectDatasForSourceIdsStatement.template valuesWithTransaction< - Storage::Synchronization::ProjectData>(64, toIntegers(projectSourceIds)); + return selectProjectDatasForSourceIdsStatement + .template valuesWithTransaction( + toIntegers(projectSourceIds)); } void setPropertyEditorPathId(TypeId typeId, SourceId pathId) @@ -595,7 +596,7 @@ private: auto fetchAllModules() const { - return selectAllModulesStatement.template valuesWithTransaction(128); + return selectAllModulesStatement.template valuesWithTransaction(); } class AliasPropertyDeclaration @@ -728,7 +729,7 @@ private: TypeIds fetchTypeIds(const SourceIds &sourceIds) { - return selectTypeIdsForSourceIdsStatement.template values(128, toIntegers(sourceIds)); + return selectTypeIdsForSourceIdsStatement.template values(toIntegers(sourceIds)); } void unique(SourceIds &sourceIds) @@ -2324,13 +2325,13 @@ private: auto fetchExportedTypes(TypeId typeId) { return selectExportedTypesByTypeIdStatement - .template values(12, typeId); + .template values(typeId); } auto fetchPropertyDeclarations(TypeId typeId) { return selectPropertyDeclarationsByTypeIdStatement - .template values(24, typeId); + .template values(typeId); } auto fetchFunctionDeclarations(TypeId typeId) @@ -2341,8 +2342,9 @@ private: Utils::SmallStringView returnType, FunctionDeclarationId functionDeclarationId) { auto &functionDeclaration = functionDeclarations.emplace_back(name, returnType); - functionDeclaration.parameters = selectFunctionParameterDeclarationsStatement.template values< - Storage::Synchronization::ParameterDeclaration>(8, functionDeclarationId); + functionDeclaration.parameters = selectFunctionParameterDeclarationsStatement + .template values(functionDeclarationId); }; selectFunctionDeclarationsForTypeIdWithoutSignatureStatement.readCallback(callback, typeId); @@ -2356,8 +2358,9 @@ private: auto callback = [&](Utils::SmallStringView name, SignalDeclarationId signalDeclarationId) { auto &signalDeclaration = signalDeclarations.emplace_back(name); - signalDeclaration.parameters = selectSignalParameterDeclarationsStatement.template values< - Storage::Synchronization::ParameterDeclaration>(8, signalDeclarationId); + signalDeclaration.parameters = selectSignalParameterDeclarationsStatement + .template values(signalDeclarationId); }; selectSignalDeclarationsForTypeIdWithoutSignatureStatement.readCallback(callback, typeId); @@ -2373,8 +2376,9 @@ private: EnumerationDeclarationId enumerationDeclarationId) { enumerationDeclarations.emplace_back( name, - selectEnumeratorDeclarationStatement.template values< - Storage::Synchronization::EnumeratorDeclaration>(8, enumerationDeclarationId)); + selectEnumeratorDeclarationStatement + .template values( + enumerationDeclarationId)); }; selectEnumerationDeclarationsForTypeIdWithoutEnumeratorDeclarationsStatement diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstorageinterface.h b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageinterface.h index b90b6efbad3..49ae0637936 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/projectstorageinterface.h +++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageinterface.h @@ -10,6 +10,8 @@ #include +#include + namespace QmlDesigner { class ProjectStorageInterface @@ -42,8 +44,8 @@ public: = 0; virtual ImportedTypeNameId importedTypeNameId(SourceId sourceId, Utils::SmallStringView typeName) = 0; - virtual PropertyDeclarationIds propertyDeclarationIds(TypeId typeId) const = 0; - virtual PropertyDeclarationIds localPropertyDeclarationIds(TypeId typeId) const = 0; + virtual QVarLengthArray propertyDeclarationIds(TypeId typeId) const = 0; + virtual QVarLengthArray localPropertyDeclarationIds(TypeId typeId) const = 0; virtual PropertyDeclarationId propertyDeclarationId(TypeId typeId, ::Utils::SmallStringView propertyName) const = 0; diff --git a/tests/unit/tests/mocks/projectstoragemock.h b/tests/unit/tests/mocks/projectstoragemock.h index 08f2f8e6b9d..61788b46db8 100644 --- a/tests/unit/tests/mocks/projectstoragemock.h +++ b/tests/unit/tests/mocks/projectstoragemock.h @@ -140,11 +140,11 @@ public: (QmlDesigner::SourceId sourceId, ::Utils::SmallStringView typeName), (override)); - MOCK_METHOD(QmlDesigner::PropertyDeclarationIds, + MOCK_METHOD((QVarLengthArray), propertyDeclarationIds, (QmlDesigner::TypeId typeId), (const, override)); - MOCK_METHOD(QmlDesigner::PropertyDeclarationIds, + MOCK_METHOD((QVarLengthArray), localPropertyDeclarationIds, (QmlDesigner::TypeId typeId), (const, override)); diff --git a/tests/unit/tests/unittests/projectstorage/projectstorage-test.cpp b/tests/unit/tests/unittests/projectstorage/projectstorage-test.cpp index 45660302627..e666493e60c 100644 --- a/tests/unit/tests/unittests/projectstorage/projectstorage-test.cpp +++ b/tests/unit/tests/unittests/projectstorage/projectstorage-test.cpp @@ -234,11 +234,15 @@ private: MATCHER(IsSorted, std::string(negation ? "isn't sorted" : "is sorted")) { + using std::begin; + using std::end; return std::is_sorted(begin(arg), end(arg)); } MATCHER(StringsAreSorted, std::string(negation ? "isn't sorted" : "is sorted")) { + using std::begin; + using std::end; return std::is_sorted(begin(arg), end(arg), [](const auto &first, const auto &second) { return Sqlite::compare(first, second) < 0; }); diff --git a/tests/unit/tests/unittests/sqlite/sqlitealgorithms-test.cpp b/tests/unit/tests/unittests/sqlite/sqlitealgorithms-test.cpp index a29a552ce59..6413cbc39a9 100644 --- a/tests/unit/tests/unittests/sqlite/sqlitealgorithms-test.cpp +++ b/tests/unit/tests/unittests/sqlite/sqlitealgorithms-test.cpp @@ -79,7 +79,7 @@ public: auto select() { return selectViewsStatement.range(); } - auto fetchKeyValues() { return selectValuesStatement.values(24); } + auto fetchKeyValues() { return selectValuesStatement.values(); } protected: Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory}; diff --git a/tests/unit/tests/unittests/sqlite/sqlitedatabase-test.cpp b/tests/unit/tests/unittests/sqlite/sqlitedatabase-test.cpp index 50b5c012c52..79f3058845b 100644 --- a/tests/unit/tests/unittests/sqlite/sqlitedatabase-test.cpp +++ b/tests/unit/tests/unittests/sqlite/sqlitedatabase-test.cpp @@ -47,7 +47,7 @@ protected: std::vector names() const { - return Sqlite::ReadStatement<1>("SELECT name FROM test", database).values(8); + return Sqlite::ReadStatement<1>("SELECT name FROM test", database).values(); } static void updateHookCallback( diff --git a/tests/unit/tests/unittests/sqlite/sqlitesessions-test.cpp b/tests/unit/tests/unittests/sqlite/sqlitesessions-test.cpp index e6d5fcc1426..4e436631560 100644 --- a/tests/unit/tests/unittests/sqlite/sqlitesessions-test.cpp +++ b/tests/unit/tests/unittests/sqlite/sqlitesessions-test.cpp @@ -102,8 +102,9 @@ class SqliteSessions : public testing::Test protected: SqliteSessions() { sessions.setAttachedTables({"data", "tags"}); } - std::vector fetchData() { return selectData.values(8); } - std::vector fetchTags() { return selectTags.values(8); } + std::vector fetchData() { return selectData.values(); } + + std::vector fetchTags() { return selectTags.values(); } protected: Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory}; diff --git a/tests/unit/tests/unittests/sqlite/sqlitestatement-test.cpp b/tests/unit/tests/unittests/sqlite/sqlitestatement-test.cpp index f56de53f041..f533c651e96 100644 --- a/tests/unit/tests/unittests/sqlite/sqlitestatement-test.cpp +++ b/tests/unit/tests/unittests/sqlite/sqlitestatement-test.cpp @@ -519,7 +519,7 @@ TEST_F(SqliteStatement, write_pointer_values) SqliteTestStatement<1, 2> statement("SELECT value FROM carray(?, ?, 'int64')", database); std::vector values{1, 1, 2, 3, 5}; - auto results = statement.values(5, values.data(), int(values.size())); + auto results = statement.values(values.data(), int(values.size())); ASSERT_THAT(results, ElementsAre(1, 1, 2, 3, 5)); } @@ -529,7 +529,7 @@ TEST_F(SqliteStatement, write_int_carray_values) SqliteTestStatement<1, 1> statement("SELECT value FROM carray(?)", database); std::vector values{3, 10, 20, 33, 55}; - auto results = statement.values(5, Utils::span(values)); + auto results = statement.values(Utils::span(values)); ASSERT_THAT(results, ElementsAre(3, 10, 20, 33, 55)); } @@ -539,7 +539,7 @@ TEST_F(SqliteStatement, write_long_long_carray_values) SqliteTestStatement<1, 1> statement("SELECT value FROM carray(?)", database); std::vector values{3, 10, 20, 33, 55}; - auto results = statement.values(5, Utils::span(values)); + auto results = statement.values(Utils::span(values)); ASSERT_THAT(results, ElementsAre(3, 10, 20, 33, 55)); } @@ -549,7 +549,7 @@ TEST_F(SqliteStatement, write_double_carray_values) SqliteTestStatement<1, 1> statement("SELECT value FROM carray(?)", database); std::vector values{3.3, 10.2, 20.54, 33.21, 55}; - auto results = statement.values(5, Utils::span(values)); + auto results = statement.values(Utils::span(values)); ASSERT_THAT(results, ElementsAre(3.3, 10.2, 20.54, 33.21, 55)); } @@ -559,7 +559,7 @@ TEST_F(SqliteStatement, write_text_carray_values) SqliteTestStatement<1, 1> statement("SELECT value FROM carray(?)", database); std::vector values{"yi", "er", "san", "se", "wu"}; - auto results = statement.values(5, Utils::span(values)); + auto results = statement.values(Utils::span(values)); ASSERT_THAT(results, ElementsAre("yi", "er", "san", "se", "wu")); } @@ -725,7 +725,7 @@ TEST_F(SqliteStatement, get_tuple_values_without_arguments) using Tuple = std::tuple; ReadStatement<3> statement("SELECT name, number, value FROM test", database); - auto values = statement.values(3); + auto values = statement.values(); ASSERT_THAT(values, UnorderedElementsAre(Tuple{"bar", 0, 1}, Tuple{"foo", 23.3, 2}, Tuple{"poo", 40.0, 3})); @@ -851,7 +851,7 @@ TEST_F(SqliteStatement, get_single_values_without_arguments) { ReadStatement<1> statement("SELECT name FROM test", database); - std::vector values = statement.values(3); + std::vector values = statement.values(); ASSERT_THAT(values, UnorderedElementsAre("bar", "foo", "poo")); } @@ -901,7 +901,7 @@ TEST_F(SqliteStatement, get_single_sqlite_values_without_arguments) ReadStatement<1> statement("SELECT number FROM test", database); database.execute("INSERT INTO test VALUES (NULL, NULL, NULL)"); - std::vector values = statement.values(3); + std::vector values = statement.values(); ASSERT_THAT(values, UnorderedElementsAre(Eq("blah"), Eq(23.3), Eq(40), IsNull())); } @@ -933,7 +933,7 @@ TEST_F(SqliteStatement, get_struct_values_without_arguments) { ReadStatement<3> statement("SELECT name, number, value FROM test", database); - auto values = statement.values(3); + auto values = statement.values(); ASSERT_THAT(values, UnorderedElementsAre(Output{"bar", "blah", 1}, @@ -971,9 +971,9 @@ TEST_F(SqliteStatement, get_struct_range_with_transaction_without_arguments) TEST_F(SqliteStatement, get_values_for_single_output_with_binding_multiple_times) { ReadStatement<1, 1> statement("SELECT name FROM test WHERE number=?", database); - statement.values(3, 40); + statement.values(40); - std::vector values = statement.values(3, 40); + std::vector values = statement.values(40); ASSERT_THAT(values, ElementsAre("poo")); } @@ -981,7 +981,7 @@ TEST_F(SqliteStatement, get_values_for_single_output_with_binding_multiple_times TEST_F(SqliteStatement, get_range_for_single_output_with_binding_multiple_times) { ReadStatement<1, 1> statement("SELECT name FROM test WHERE number=?", database); - statement.values(3, 40); + statement.values(40); auto range = statement.range(40); std::vector values{range.begin(), range.end()}; @@ -992,7 +992,7 @@ TEST_F(SqliteStatement, get_range_for_single_output_with_binding_multiple_times) TEST_F(SqliteStatement, get_range_with_transaction_for_single_output_with_binding_multiple_times) { ReadStatement<1, 1> statement("SELECT name FROM test WHERE number=?", database); - statement.values(3, 40); + statement.values(40); database.unlock(); std::vector values = toValues( @@ -1008,7 +1008,7 @@ TEST_F(SqliteStatement, get_values_for_multiple_output_values_and_multiple_query ReadStatement<3, 3> statement( "SELECT name, number, value FROM test WHERE name=? AND number=? AND value=?", database); - auto values = statement.values(3, "bar", "blah", 1); + auto values = statement.values("bar", "blah", 1); ASSERT_THAT(values, ElementsAre(Tuple{"bar", "blah", 1})); } @@ -1043,9 +1043,9 @@ TEST_F(SqliteStatement, call_get_values_for_multiple_output_values_and_multiple_ using Tuple = std::tuple; ReadStatement<3, 2> statement("SELECT name, number, value FROM test WHERE name=? AND number=?", database); - statement.values(3, "bar", "blah"); + statement.values("bar", "blah"); - auto values = statement.values(3, "bar", "blah"); + auto values = statement.values("bar", "blah"); ASSERT_THAT(values, ElementsAre(Tuple{"bar", "blah", 1})); } @@ -1086,7 +1086,7 @@ TEST_F(SqliteStatement, get_struct_output_values_and_multiple_query_value) ReadStatement<3, 3> statement( "SELECT name, number, value FROM test WHERE name=? AND number=? AND value=?", database); - auto values = statement.values(3, "bar", "blah", 1); + auto values = statement.values("bar", "blah", 1); ASSERT_THAT(values, ElementsAre(Output{"bar", "blah", 1})); } @@ -1099,7 +1099,7 @@ TEST_F(SqliteStatement, get_blob_values) auto bytePointer = reinterpret_cast(&value); Sqlite::BlobView bytes{bytePointer, 4}; - auto values = statement.values(1); + auto values = statement.values(); ASSERT_THAT(values, ElementsAre(Field(&Sqlite::Blob::bytes, Eq(bytes)))); } @@ -1299,7 +1299,7 @@ TEST_F(SqliteStatement, get_values_without_arguments_calls_reset) EXPECT_CALL(mockStatement, reset()); - mockStatement.values(3); + mockStatement.values(); } TEST_F(SqliteStatement, get_range_without_arguments_calls_reset) @@ -1332,7 +1332,7 @@ TEST_F(SqliteStatement, get_values_without_arguments_calls_reset_if_exception_is EXPECT_CALL(mockStatement, reset()); - EXPECT_THROW(mockStatement.values(3), Sqlite::StatementHasError); + EXPECT_THROW(mockStatement.values(), Sqlite::StatementHasError); } TEST_F(SqliteStatement, get_range_without_arguments_calls_reset_if_exception_is_thrown) @@ -1372,7 +1372,7 @@ TEST_F(SqliteStatement, get_values_with_simple_arguments_calls_reset) EXPECT_CALL(mockStatement, reset()); - mockStatement.values(3, "foo", "bar"); + mockStatement.values("foo", "bar"); } TEST_F(SqliteStatement, get_values_with_simple_arguments_calls_reset_if_exception_is_thrown) @@ -1382,7 +1382,7 @@ TEST_F(SqliteStatement, get_values_with_simple_arguments_calls_reset_if_exceptio EXPECT_CALL(mockStatement, reset()); - EXPECT_THROW(mockStatement.values(3, "foo", "bar"), Sqlite::StatementHasError); + EXPECT_THROW((mockStatement.values("foo", "bar")), Sqlite::StatementHasError); } TEST_F(SqliteStatement, reset_if_write_is_throwing_exception) @@ -1580,7 +1580,7 @@ TEST_F(SqliteStatement, read_statement_values_with_transactions) database); database.unlock(); - std::vector values = statement.valuesWithTransaction(1024, "bar", "blah"); + std::vector values = statement.valuesWithTransaction("bar", "blah"); ASSERT_THAT(values, ElementsAre(Tuple{"bar", "blah", 1})); database.lock(); @@ -1646,7 +1646,7 @@ TEST_F(SqliteStatement, read_write_statement_values_with_transactions) "SELECT name, number, value FROM test WHERE name=? AND number=?", database); database.unlock(); - std::vector values = statement.valuesWithTransaction(1024, "bar", "blah"); + std::vector values = statement.valuesWithTransaction("bar", "blah"); ASSERT_THAT(values, ElementsAre(Tuple{"bar", "blah", 1})); database.lock();