diff options
author | John Turner <jturner.usa@gmail.com> | 2025-09-14 00:16:10 -0400 |
---|---|---|
committer | John Turner <jturner.usa@gmail.com> | 2025-09-14 00:16:10 -0400 |
commit | 13e0821fd783a1d5083d825af53cf20e8dcbfd76 (patch) | |
tree | 1ea363b0f13b3e87d177100e6ae6b9f30a2de1b8 /subprojects/boost-sqlite/test/hooks.cpp | |
parent | aa55cb93036a89c64c08e08f4e1de4fa1fd5a775 (diff) | |
parent | efcea3a80da7c4479d5fe168435ecc9fd06bdc72 (diff) | |
download | sqlite-kv-bench-13e0821fd783a1d5083d825af53cf20e8dcbfd76.tar.gz |
Merge commit 'efcea3a80da7c4479d5fe168435ecc9fd06bdc72' as 'subprojects/boost-sqlite'
Diffstat (limited to 'subprojects/boost-sqlite/test/hooks.cpp')
-rw-r--r-- | subprojects/boost-sqlite/test/hooks.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/subprojects/boost-sqlite/test/hooks.cpp b/subprojects/boost-sqlite/test/hooks.cpp new file mode 100644 index 0000000..2aa371f --- /dev/null +++ b/subprojects/boost-sqlite/test/hooks.cpp @@ -0,0 +1,52 @@ +// Copyright (c) 2022 Klemens D. Morgenstern +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/sqlite/hooks.hpp> +#include <boost/sqlite/connection.hpp> +#include "test.hpp" + +using namespace boost; + +BOOST_AUTO_TEST_CASE(hooks) +{ + sqlite::connection conn(":memory:"); + conn.execute( +#include "test-db.sql" + ); + + bool called = false; + auto l = + [&](int op, core::string_view db, core::string_view table, sqlite3_int64 ) noexcept + { + BOOST_CHECK(op == SQLITE_INSERT); + BOOST_CHECK(db == "main"); + BOOST_CHECK(table == "library"); + called = true; + }; + + + sqlite::update_hook(conn, l); + // language=sqlite + conn.query(R"( + insert into library ("name", "author") values + ('mustache',(select id from author where first_name = 'peter' and last_name = 'dimov')); + )"); + + BOOST_CHECK(called); + +#if defined(SQLITE_ENABLE_PREUPDATE_HOOK) + auto hk = [](sqlite::preupdate_context ctx, + int op, + const char * db_name, + const char * table_name, + sqlite3_int64 current_key, + sqlite3_int64 new_key) noexcept + { + + }; + + preupdate_hook(conn, hk); +#endif +} |