From 91ebcef7d00e15fa49805373467d7c1daeda1ba7 Mon Sep 17 00:00:00 2001 From: a <28563107+aphage@users.noreply.github.com> Date: Thu, 29 Sep 2022 14:13:12 +0800 Subject: [PATCH 01/22] fix: catch2 --- dependencies/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dependencies/CMakeLists.txt b/dependencies/CMakeLists.txt index 7078b1bd3..9d4934238 100644 --- a/dependencies/CMakeLists.txt +++ b/dependencies/CMakeLists.txt @@ -4,11 +4,11 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) FetchContent_Declare( catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2.git - GIT_TAG v2.13.2 + GIT_TAG v2.13.5 ) endif() if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) add_subdirectory(catch2) endif() -add_subdirectory(sqlite3) \ No newline at end of file +add_subdirectory(sqlite3) From 94d2f764f636a45fd98ce2d187246eb6ea438d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Iardella?= <49476401+rotolof@users.noreply.github.com> Date: Mon, 19 Dec 2022 09:27:10 +0100 Subject: [PATCH 02/22] Use PROJECT_NAME in main CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 436d30a6d..6626e2146 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_VERBOSE_MAKEFILE ON) -message(STATUS "Configuring ${CMAKE_PROJECT_NAME} ${sqlite_orm_VERSION}") +message(STATUS "Configuring ${PROJECT_NAME} ${sqlite_orm_VERSION}") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") From f7760850d5cfd2df6c4f276972a0784dc92f4499 Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Sun, 15 Jan 2023 21:18:26 +0200 Subject: [PATCH 03/22] Corrected passing warning flags to msvc --- tests/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f1095b369..d816ebc33 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -141,19 +141,19 @@ if (MSVC) if (MSVC_VERSION LESS_EQUAL 1900) target_compile_options(unit_tests PUBLIC # C4503: decorated name length exceeded - /wd"4503" + /wd4503 # C4800: forcing value to bool (performance warning) - /wd"4800") + /wd4800) else() target_compile_options(unit_tests PUBLIC # warning-level 4 /W4 # C4127: conditional expression is constant - /wd"4127" + /wd4127 # C4456: declaration of 'symbol' hides previous local declaration - /wd"4456" + /wd4456 # C4458: declaration of 'symbol' hides class member - /wd"4458") + /wd4458) endif() endif() From 3154d24423e54cb1704d36107ea576eb4372a508 Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Sun, 15 Jan 2023 21:59:58 +0200 Subject: [PATCH 04/22] Updated to Catch2 v3 --- appveyor.yml | 8 +++++++- dev/statement_serializer.h | 2 +- tests/CMakeLists.txt | 6 ++---- tests/ast_iterator_tests.cpp | 2 +- tests/backup_tests.cpp | 2 +- .../core_functions_tests.cpp | 2 +- .../datetime_function_tests.cpp | 2 +- tests/built_in_functions_tests/math_functions.cpp | 2 +- tests/column_tests.cpp | 2 +- tests/constraints/check.cpp | 2 +- tests/constraints/composite_key.cpp | 2 +- tests/constraints/default.cpp | 2 +- tests/constraints/foreign_key.cpp | 2 +- tests/constraints/unique.cpp | 8 ++++---- tests/explicit_columns.cpp | 2 +- tests/filename.cpp | 2 +- tests/get_all_custom_containers.cpp | 2 +- tests/index_tests.cpp | 6 +++--- tests/json.cpp | 2 +- tests/operators/arithmetic_operators.cpp | 2 +- tests/operators/between.cpp | 2 +- tests/operators/binary_operators.cpp | 2 +- tests/operators/bitwise.cpp | 2 +- tests/operators/cast.cpp | 2 +- tests/operators/glob.cpp | 2 +- tests/operators/in.cpp | 2 +- tests/operators/is_null.cpp | 2 +- tests/operators/like.cpp | 2 +- tests/operators/not_operator.cpp | 2 +- tests/pointer_passing_interface.cpp | 2 +- tests/pragma_tests.cpp | 2 +- tests/prepared_statement_tests/column_names.cpp | 2 +- tests/prepared_statement_tests/get.cpp | 8 ++++---- tests/prepared_statement_tests/get_all.cpp | 2 +- tests/prepared_statement_tests/get_all_optional.cpp | 2 +- tests/prepared_statement_tests/get_all_pointer.cpp | 2 +- tests/prepared_statement_tests/get_optional.cpp | 2 +- tests/prepared_statement_tests/get_pointer.cpp | 2 +- tests/prepared_statement_tests/insert.cpp | 2 +- tests/prepared_statement_tests/insert_explicit.cpp | 6 +++--- tests/prepared_statement_tests/insert_range.cpp | 8 ++++---- tests/prepared_statement_tests/remove.cpp | 2 +- tests/prepared_statement_tests/remove_all.cpp | 2 +- tests/prepared_statement_tests/replace.cpp | 2 +- tests/prepared_statement_tests/replace_range.cpp | 8 ++++---- tests/prepared_statement_tests/select.cpp | 2 +- tests/prepared_statement_tests/update.cpp | 2 +- tests/prepared_statement_tests/update_all.cpp | 2 +- tests/private_getters_tests.cpp | 2 +- tests/row_id.cpp | 2 +- tests/select_constraints_tests.cpp | 2 +- tests/simple_query.cpp | 2 +- .../aggregate_functions.cpp | 2 +- .../statement_serializer_tests/alias_extractor.cpp | 2 +- .../arithmetic_operators.cpp | 2 +- tests/statement_serializer_tests/ast/excluded.cpp | 2 +- .../ast/upsert_clause.cpp | 2 +- tests/statement_serializer_tests/base_types.cpp | 2 +- tests/statement_serializer_tests/bindables.cpp | 2 +- tests/statement_serializer_tests/collate.cpp | 2 +- .../column_constraints/autoincrement.cpp | 2 +- .../column_constraints/check.cpp | 2 +- .../column_constraints/default.cpp | 2 +- .../column_constraints/generated.cpp | 2 +- .../column_constraints/primary_key.cpp | 2 +- .../column_constraints/unique.cpp | 2 +- tests/statement_serializer_tests/column_names.cpp | 2 +- .../comparison_operators.cpp | 2 +- tests/statement_serializer_tests/conditions.cpp | 2 +- tests/statement_serializer_tests/core_functions.cpp | 2 +- tests/statement_serializer_tests/foreign_key.cpp | 2 +- tests/statement_serializer_tests/indexed_column.cpp | 2 +- .../logical_operators.cpp | 2 +- tests/statement_serializer_tests/rowid.cpp | 2 +- tests/statement_serializer_tests/schema/index.cpp | 2 +- tests/statement_serializer_tests/schema/new_old.cpp | 2 +- tests/statement_serializer_tests/schema/raise.cpp | 2 +- tests/statement_serializer_tests/schema/trigger.cpp | 2 +- .../select_constraints.cpp | 2 +- .../statements/insert_replace.cpp | 2 +- .../statements/remove.cpp | 2 +- .../statements/remove_all.cpp | 2 +- .../statements/select.cpp | 2 +- .../statements/update.cpp | 2 +- .../statements/update_all.cpp | 2 +- .../aggregate_function_return_types.cpp | 2 +- .../arithmetic_operators_result_type.cpp | 2 +- tests/static_tests/bindable_filter.cpp | 2 +- tests/static_tests/column.cpp | 2 +- tests/static_tests/column_result_t.cpp | 2 +- tests/static_tests/compound_operators.cpp | 2 +- tests/static_tests/core_function_return_types.cpp | 2 +- tests/static_tests/foreign_key.cpp | 2 +- tests/static_tests/function_static_tests.cpp | 2 +- tests/static_tests/functional/mpl.cpp | 2 +- tests/static_tests/functional/same_or_void.cpp | 2 +- tests/static_tests/functional/static_if_tests.cpp | 2 +- tests/static_tests/functional/tuple_conc.cpp | 2 +- tests/static_tests/functional/tuple_filter.cpp | 2 +- tests/static_tests/functional/tuple_traits.cpp | 2 +- tests/static_tests/functional/tuple_transform.cpp | 2 +- tests/static_tests/is_bindable.cpp | 2 +- .../is_column_with_insertable_primary_key.cpp | 2 +- tests/static_tests/is_primary_key_insertable.cpp | 2 +- tests/static_tests/is_printable.cpp | 2 +- tests/static_tests/iterator_t.cpp | 2 +- tests/static_tests/member_traits_tests.cpp | 2 +- tests/static_tests/node_tuple.cpp | 2 +- tests/static_tests/select_return_type.cpp | 2 +- tests/storage_non_crud_tests.cpp | 8 ++++---- tests/storage_tests.cpp | 2 +- tests/sync_schema_tests.cpp | 2 +- tests/table_tests.cpp | 2 +- tests/tests.cpp | 13 +++++-------- tests/tests2.cpp | 6 +++--- tests/tests3.cpp | 2 +- tests/tests4.cpp | 2 +- tests/tests5.cpp | 2 +- tests/transaction_tests.cpp | 6 +++--- tests/trigger_tests.cpp | 2 +- tests/tuple_iteration.cpp | 2 +- tests/unique_cases/delete_with_two_fields.cpp | 2 +- tests/unique_cases/get_all_with_two_tables.cpp | 2 +- tests/unique_cases/index_named_table_with_fk.cpp | 2 +- tests/unique_cases/issue525.cpp | 2 +- tests/unique_cases/issue663.cpp | 2 +- tests/unique_cases/issue86.cpp | 2 +- tests/unique_cases/issue937.cpp | 2 +- .../join_iterator_ctor_compilation_error.cpp | 2 +- tests/unique_cases/prepare_get_all_with_case.cpp | 2 +- 130 files changed, 164 insertions(+), 163 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 69743a6b8..205cadb12 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -96,6 +96,10 @@ for: if "%appveyor_build_worker_image%"=="Visual Studio 2015" (set generator="Visual Studio 14 2015" %architecture%) install: - |- + cd C:\Tools\vcpkg + git clone --depth 1 --branch 2023.01.09 https://github.com/microsoft/vcpkg.git "$HOME/vcpkg" + .\bootstrap-vcpkg.bat + cd "%APPVEYOR_BUILD_FOLDER%" C:\Tools\vcpkg\vcpkg integrate install vcpkg install sqlite3:%platform%-windows before_build: @@ -121,6 +125,8 @@ for: # using custom vcpkg triplets for building and linking dynamic dependent libraries install: - |- + git clone --depth 1 --branch 2023.01.09 https://github.com/microsoft/vcpkg.git $HOME/vcpkg + $HOME/vcpkg/booststrap.sh $HOME/vcpkg/vcpkg integrate install --overlay-triplets=vcpkg/triplets vcpkg install sqlite3 --overlay-triplets=vcpkg/triplets before_build: @@ -145,7 +151,7 @@ for: # using custom vcpkg triplets for building and linking dynamic dependent libraries install: - |- - git clone --depth 1 --branch 2022.05.10 https://github.com/microsoft/vcpkg.git $HOME/vcpkg + git clone --depth 1 --branch 2023.01.09 https://github.com/microsoft/vcpkg.git $HOME/vcpkg $HOME/vcpkg/booststrap.sh $HOME/vcpkg/vcpkg integrate install --overlay-triplets=vcpkg/triplets vcpkg install sqlite3 --overlay-triplets=vcpkg/triplets diff --git a/dev/statement_serializer.h b/dev/statement_serializer.h index cfe5dac2c..28ae2b8f4 100644 --- a/dev/statement_serializer.h +++ b/dev/statement_serializer.h @@ -788,7 +788,7 @@ namespace sqlite_orm { using statement_type = conflict_clause_t; template - std::string operator()(const statement_type& statement, const Ctx& context) const { + std::string operator()(const statement_type& statement, const Ctx&) const { switch(statement) { case conflict_clause_t::rollback: return "ROLLBACK"; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d816ebc33..69e491383 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -159,11 +159,9 @@ endif() target_precompile_headers(unit_tests PRIVATE - ) -# tests.cpp contains CATCH_CONFIG_MAIN -set_source_files_properties(tests.cpp PROPERTIES SKIP_PRECOMPILE_HEADERS ON) + ) -target_link_libraries(unit_tests PRIVATE sqlite_orm Catch2::Catch2) +target_link_libraries(unit_tests PRIVATE sqlite_orm Catch2::Catch2WithMain) add_test(NAME "All_in_one_unit_test" COMMAND unit_tests diff --git a/tests/ast_iterator_tests.cpp b/tests/ast_iterator_tests.cpp index 746cfd852..761548e4d 100644 --- a/tests/ast_iterator_tests.cpp +++ b/tests/ast_iterator_tests.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/backup_tests.cpp b/tests/backup_tests.cpp index 7db85cb8c..0f127cd0d 100644 --- a/tests/backup_tests.cpp +++ b/tests/backup_tests.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include // remove using namespace sqlite_orm; diff --git a/tests/built_in_functions_tests/core_functions_tests.cpp b/tests/built_in_functions_tests/core_functions_tests.cpp index 253970b7a..312cbc85d 100644 --- a/tests/built_in_functions_tests/core_functions_tests.cpp +++ b/tests/built_in_functions_tests/core_functions_tests.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/built_in_functions_tests/datetime_function_tests.cpp b/tests/built_in_functions_tests/datetime_function_tests.cpp index 4cc113e15..b6e0812b9 100644 --- a/tests/built_in_functions_tests/datetime_function_tests.cpp +++ b/tests/built_in_functions_tests/datetime_function_tests.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/built_in_functions_tests/math_functions.cpp b/tests/built_in_functions_tests/math_functions.cpp index 644643b29..47d9df290 100644 --- a/tests/built_in_functions_tests/math_functions.cpp +++ b/tests/built_in_functions_tests/math_functions.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/column_tests.cpp b/tests/column_tests.cpp index 28e2ddd46..df7c25d66 100644 --- a/tests/column_tests.cpp +++ b/tests/column_tests.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/constraints/check.cpp b/tests/constraints/check.cpp index e6129f799..233d84873 100644 --- a/tests/constraints/check.cpp +++ b/tests/constraints/check.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/constraints/composite_key.cpp b/tests/constraints/composite_key.cpp index 95a69ca31..91d9b06f0 100644 --- a/tests/constraints/composite_key.cpp +++ b/tests/constraints/composite_key.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/constraints/default.cpp b/tests/constraints/default.cpp index 6658e8f73..e59c63ee0 100644 --- a/tests/constraints/default.cpp +++ b/tests/constraints/default.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/constraints/foreign_key.cpp b/tests/constraints/foreign_key.cpp index 794a7f28e..436b69503 100644 --- a/tests/constraints/foreign_key.cpp +++ b/tests/constraints/foreign_key.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include // std::is_same diff --git a/tests/constraints/unique.cpp b/tests/constraints/unique.cpp index 561f768bc..300570a60 100644 --- a/tests/constraints/unique.cpp +++ b/tests/constraints/unique.cpp @@ -1,10 +1,10 @@ #include -#include +#include using namespace sqlite_orm; TEST_CASE("Unique") { - using Catch::Matchers::Contains; + using Catch::Matchers::ContainsSubstring; struct Contact { int id = 0; @@ -57,11 +57,11 @@ TEST_CASE("Unique") { storage.insert(Contact{0, "John", "Doe", "john.doe@gmail.com"}); REQUIRE_THROWS_WITH(storage.insert(Contact{0, "Johnny", "Doe", "john.doe@gmail.com"}), - Contains("constraint failed")); + ContainsSubstring("constraint failed")); storage.insert(Shape{0, "red", "green"}); storage.insert(Shape{0, "red", "blue"}); - REQUIRE_THROWS_WITH(storage.insert(Shape{0, "red", "green"}), Contains("constraint failed")); + REQUIRE_THROWS_WITH(storage.insert(Shape{0, "red", "green"}), ContainsSubstring("constraint failed")); std::vector lists(2); REQUIRE_NOTHROW(storage.insert_range(lists.begin(), lists.end())); diff --git a/tests/explicit_columns.cpp b/tests/explicit_columns.cpp index 9817b6ad8..5762aa8e2 100644 --- a/tests/explicit_columns.cpp +++ b/tests/explicit_columns.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/filename.cpp b/tests/filename.cpp index 5f1e72262..e779ab836 100644 --- a/tests/filename.cpp +++ b/tests/filename.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/get_all_custom_containers.cpp b/tests/get_all_custom_containers.cpp index 55ff0f505..00eaf931d 100644 --- a/tests/get_all_custom_containers.cpp +++ b/tests/get_all_custom_containers.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/tests/index_tests.cpp b/tests/index_tests.cpp index 98396a90e..f0bfa5ef3 100644 --- a/tests/index_tests.cpp +++ b/tests/index_tests.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; @@ -48,7 +48,7 @@ TEST_CASE("index") { #ifdef SQLITE_ORM_OPTIONAL_SUPPORTED TEST_CASE("filtered index") { - using Catch::Matchers::Contains; + using Catch::Matchers::ContainsSubstring; struct Test { std::optional field1 = 0; @@ -62,7 +62,7 @@ TEST_CASE("filtered index") { REQUIRE_NOTHROW(storage.sync_schema()); storage.insert(Test{1, std::nullopt}); - REQUIRE_THROWS_WITH(storage.insert(Test{1, std::nullopt}), Contains("constraint failed")); + REQUIRE_THROWS_WITH(storage.insert(Test{1, std::nullopt}), ContainsSubstring("constraint failed")); } SECTION("2") { auto storage = make_storage( diff --git a/tests/json.cpp b/tests/json.cpp index 48cb973c9..1f5769782 100644 --- a/tests/json.cpp +++ b/tests/json.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/operators/arithmetic_operators.cpp b/tests/operators/arithmetic_operators.cpp index 07e7c42d1..d0d92083d 100644 --- a/tests/operators/arithmetic_operators.cpp +++ b/tests/operators/arithmetic_operators.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/operators/between.cpp b/tests/operators/between.cpp index dac17f575..c1e52f1fa 100644 --- a/tests/operators/between.cpp +++ b/tests/operators/between.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/operators/binary_operators.cpp b/tests/operators/binary_operators.cpp index a1c14e9ba..89ad8667a 100644 --- a/tests/operators/binary_operators.cpp +++ b/tests/operators/binary_operators.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/operators/bitwise.cpp b/tests/operators/bitwise.cpp index 4749b5d13..7492a2c12 100644 --- a/tests/operators/bitwise.cpp +++ b/tests/operators/bitwise.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/operators/cast.cpp b/tests/operators/cast.cpp index a214de379..9122f72af 100644 --- a/tests/operators/cast.cpp +++ b/tests/operators/cast.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/operators/glob.cpp b/tests/operators/glob.cpp index 2c87ca684..d44c92ab1 100644 --- a/tests/operators/glob.cpp +++ b/tests/operators/glob.cpp @@ -2,7 +2,7 @@ * Obtained from here https://www.tutlane.com/tutorial/sqlite/sqlite-glob-operator */ #include -#include +#include #include // std::vector #include // std::find_if, std::count diff --git a/tests/operators/in.cpp b/tests/operators/in.cpp index a4b570d29..e48b1a93a 100644 --- a/tests/operators/in.cpp +++ b/tests/operators/in.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/operators/is_null.cpp b/tests/operators/is_null.cpp index c9a1218c6..c358ab3f0 100644 --- a/tests/operators/is_null.cpp +++ b/tests/operators/is_null.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/operators/like.cpp b/tests/operators/like.cpp index 3f7bb9e8b..18a701cf6 100644 --- a/tests/operators/like.cpp +++ b/tests/operators/like.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/operators/not_operator.cpp b/tests/operators/not_operator.cpp index 786b42fad..78b40c1d0 100644 --- a/tests/operators/not_operator.cpp +++ b/tests/operators/not_operator.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/pointer_passing_interface.cpp b/tests/pointer_passing_interface.cpp index b9eafb9b0..5a13c80c6 100644 --- a/tests/pointer_passing_interface.cpp +++ b/tests/pointer_passing_interface.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; using std::unique_ptr; diff --git a/tests/pragma_tests.cpp b/tests/pragma_tests.cpp index d4099a0c4..691e9cb42 100644 --- a/tests/pragma_tests.cpp +++ b/tests/pragma_tests.cpp @@ -1,6 +1,6 @@ #include #include // ::remove -#include +#include using namespace sqlite_orm; diff --git a/tests/prepared_statement_tests/column_names.cpp b/tests/prepared_statement_tests/column_names.cpp index 09350ca9d..2bb5cbea6 100644 --- a/tests/prepared_statement_tests/column_names.cpp +++ b/tests/prepared_statement_tests/column_names.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/prepared_statement_tests/get.cpp b/tests/prepared_statement_tests/get.cpp index cf780b9eb..5add455e4 100644 --- a/tests/prepared_statement_tests/get.cpp +++ b/tests/prepared_statement_tests/get.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "prepared_common.h" @@ -7,7 +7,7 @@ using namespace sqlite_orm; TEST_CASE("Prepared get") { using namespace PreparedStatementTests; - using Catch::Matchers::Contains; + using Catch::Matchers::ContainsSubstring; using Catch::Matchers::UnorderedEquals; const int defaultVisitTime = 50; @@ -72,7 +72,7 @@ TEST_CASE("Prepared get") { } { get<0>(statement) = 4; - REQUIRE_THROWS_WITH(storage.execute(statement), Contains("Not found")); + REQUIRE_THROWS_WITH(storage.execute(statement), ContainsSubstring("Not found")); } } } @@ -94,7 +94,7 @@ TEST_CASE("Prepared get") { //.. } SECTION("execute") { - REQUIRE_THROWS_WITH(storage.execute(statement), Contains("Not found")); + REQUIRE_THROWS_WITH(storage.execute(statement), ContainsSubstring("Not found")); } } { diff --git a/tests/prepared_statement_tests/get_all.cpp b/tests/prepared_statement_tests/get_all.cpp index 6d85bba48..5f40fa7f2 100644 --- a/tests/prepared_statement_tests/get_all.cpp +++ b/tests/prepared_statement_tests/get_all.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "prepared_common.h" diff --git a/tests/prepared_statement_tests/get_all_optional.cpp b/tests/prepared_statement_tests/get_all_optional.cpp index e49de3259..55db5512b 100644 --- a/tests/prepared_statement_tests/get_all_optional.cpp +++ b/tests/prepared_statement_tests/get_all_optional.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "prepared_common.h" diff --git a/tests/prepared_statement_tests/get_all_pointer.cpp b/tests/prepared_statement_tests/get_all_pointer.cpp index c8a7c3bbc..f02326b9a 100644 --- a/tests/prepared_statement_tests/get_all_pointer.cpp +++ b/tests/prepared_statement_tests/get_all_pointer.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "prepared_common.h" diff --git a/tests/prepared_statement_tests/get_optional.cpp b/tests/prepared_statement_tests/get_optional.cpp index 2fe611a32..0ce3bd583 100644 --- a/tests/prepared_statement_tests/get_optional.cpp +++ b/tests/prepared_statement_tests/get_optional.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "prepared_common.h" diff --git a/tests/prepared_statement_tests/get_pointer.cpp b/tests/prepared_statement_tests/get_pointer.cpp index 46f6a30f1..e5b8c26a5 100644 --- a/tests/prepared_statement_tests/get_pointer.cpp +++ b/tests/prepared_statement_tests/get_pointer.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "prepared_common.h" diff --git a/tests/prepared_statement_tests/insert.cpp b/tests/prepared_statement_tests/insert.cpp index c101033e1..087a3dc87 100644 --- a/tests/prepared_statement_tests/insert.cpp +++ b/tests/prepared_statement_tests/insert.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "prepared_common.h" diff --git a/tests/prepared_statement_tests/insert_explicit.cpp b/tests/prepared_statement_tests/insert_explicit.cpp index 85d26c750..f787f1f50 100644 --- a/tests/prepared_statement_tests/insert_explicit.cpp +++ b/tests/prepared_statement_tests/insert_explicit.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "prepared_common.h" @@ -7,7 +7,7 @@ using namespace sqlite_orm; TEST_CASE("Prepared insert explicit") { using namespace PreparedStatementTests; - using Catch::Matchers::Contains; + using Catch::Matchers::ContainsSubstring; using Catch::Matchers::UnorderedEquals; const int defaultVisitTime = 50; @@ -67,7 +67,7 @@ TEST_CASE("Prepared insert explicit") { { user.id = 6; user.name = "Nate Dogg"; - REQUIRE_THROWS_WITH(storage.execute(statement), Contains("constraint failed")); + REQUIRE_THROWS_WITH(storage.execute(statement), ContainsSubstring("constraint failed")); get<0>(statement) = user; auto insertedId = storage.execute(statement); diff --git a/tests/prepared_statement_tests/insert_range.cpp b/tests/prepared_statement_tests/insert_range.cpp index 763b5df16..388d22ba8 100644 --- a/tests/prepared_statement_tests/insert_range.cpp +++ b/tests/prepared_statement_tests/insert_range.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include "prepared_common.h" @@ -8,7 +8,7 @@ using namespace sqlite_orm; TEST_CASE("Prepared insert range") { using namespace PreparedStatementTests; - using Catch::Matchers::Contains; + using Catch::Matchers::ContainsSubstring; using Catch::Matchers::UnorderedEquals; const int defaultVisitTime = 50; @@ -48,14 +48,14 @@ TEST_CASE("Prepared insert range") { SECTION("empty") { SECTION("strict") { REQUIRE_THROWS_WITH(storage.prepare(insert_range(users.begin(), users.end())), - Contains("incomplete input")); + ContainsSubstring("incomplete input")); } SECTION("container with pointers") { std::vector> usersPointers; REQUIRE_THROWS_WITH( storage.prepare( insert_range(usersPointers.begin(), usersPointers.end(), &std::unique_ptr::operator*)), - Contains("incomplete input")); + ContainsSubstring("incomplete input")); } } SECTION("one") { diff --git a/tests/prepared_statement_tests/remove.cpp b/tests/prepared_statement_tests/remove.cpp index cd757ae31..7e0664d6c 100644 --- a/tests/prepared_statement_tests/remove.cpp +++ b/tests/prepared_statement_tests/remove.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "prepared_common.h" diff --git a/tests/prepared_statement_tests/remove_all.cpp b/tests/prepared_statement_tests/remove_all.cpp index ebc51bb15..fafc0fdf7 100644 --- a/tests/prepared_statement_tests/remove_all.cpp +++ b/tests/prepared_statement_tests/remove_all.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "prepared_common.h" diff --git a/tests/prepared_statement_tests/replace.cpp b/tests/prepared_statement_tests/replace.cpp index 2935d8148..45f177540 100644 --- a/tests/prepared_statement_tests/replace.cpp +++ b/tests/prepared_statement_tests/replace.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "prepared_common.h" diff --git a/tests/prepared_statement_tests/replace_range.cpp b/tests/prepared_statement_tests/replace_range.cpp index 5f9cb15cc..aeca31240 100644 --- a/tests/prepared_statement_tests/replace_range.cpp +++ b/tests/prepared_statement_tests/replace_range.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "prepared_common.h" @@ -44,18 +44,18 @@ TEST_CASE("Prepared replace range") { return *pointer; }; SECTION("empty") { - using namespace Catch::Matchers; + using Catch::Matchers::ContainsSubstring; expected.push_back(User{1, "Team BS"}); expected.push_back(User{2, "Shy'm"}); expected.push_back(User{3, "MaƮtre Gims"}); SECTION("straight") { REQUIRE_THROWS_WITH(storage.prepare(replace_range(users.begin(), users.end())), - Contains("incomplete input")); + ContainsSubstring("incomplete input")); } SECTION("pointers") { REQUIRE_THROWS_WITH(storage.prepare(replace_range(userPointers.begin(), userPointers.end(), lambda)), - Contains("incomplete input")); + ContainsSubstring("incomplete input")); } } SECTION("one existing") { diff --git a/tests/prepared_statement_tests/select.cpp b/tests/prepared_statement_tests/select.cpp index 8971d49d3..255879d68 100644 --- a/tests/prepared_statement_tests/select.cpp +++ b/tests/prepared_statement_tests/select.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "prepared_common.h" diff --git a/tests/prepared_statement_tests/update.cpp b/tests/prepared_statement_tests/update.cpp index 64046cccf..666274dea 100644 --- a/tests/prepared_statement_tests/update.cpp +++ b/tests/prepared_statement_tests/update.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "prepared_common.h" diff --git a/tests/prepared_statement_tests/update_all.cpp b/tests/prepared_statement_tests/update_all.cpp index a56b0304b..cfa711777 100644 --- a/tests/prepared_statement_tests/update_all.cpp +++ b/tests/prepared_statement_tests/update_all.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "prepared_common.h" diff --git a/tests/private_getters_tests.cpp b/tests/private_getters_tests.cpp index 57ba1efd0..21e72400c 100644 --- a/tests/private_getters_tests.cpp +++ b/tests/private_getters_tests.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include using namespace sqlite_orm; diff --git a/tests/row_id.cpp b/tests/row_id.cpp index 7c3892371..2b65c1d61 100644 --- a/tests/row_id.cpp +++ b/tests/row_id.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/select_constraints_tests.cpp b/tests/select_constraints_tests.cpp index 1b73587ab..bf085276c 100644 --- a/tests/select_constraints_tests.cpp +++ b/tests/select_constraints_tests.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/simple_query.cpp b/tests/simple_query.cpp index bdeb9199a..e98617581 100644 --- a/tests/simple_query.cpp +++ b/tests/simple_query.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/aggregate_functions.cpp b/tests/statement_serializer_tests/aggregate_functions.cpp index 13df94dce..5474ddc9e 100644 --- a/tests/statement_serializer_tests/aggregate_functions.cpp +++ b/tests/statement_serializer_tests/aggregate_functions.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/alias_extractor.cpp b/tests/statement_serializer_tests/alias_extractor.cpp index f29c0fdd4..3982acb95 100644 --- a/tests/statement_serializer_tests/alias_extractor.cpp +++ b/tests/statement_serializer_tests/alias_extractor.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; using internal::alias_extractor; diff --git a/tests/statement_serializer_tests/arithmetic_operators.cpp b/tests/statement_serializer_tests/arithmetic_operators.cpp index 538998c5a..29248eb54 100644 --- a/tests/statement_serializer_tests/arithmetic_operators.cpp +++ b/tests/statement_serializer_tests/arithmetic_operators.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/ast/excluded.cpp b/tests/statement_serializer_tests/ast/excluded.cpp index 23969b1ae..d84b64f21 100644 --- a/tests/statement_serializer_tests/ast/excluded.cpp +++ b/tests/statement_serializer_tests/ast/excluded.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/ast/upsert_clause.cpp b/tests/statement_serializer_tests/ast/upsert_clause.cpp index a7a3bf3d9..ab36b5e87 100644 --- a/tests/statement_serializer_tests/ast/upsert_clause.cpp +++ b/tests/statement_serializer_tests/ast/upsert_clause.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/base_types.cpp b/tests/statement_serializer_tests/base_types.cpp index 2b3075645..142f649da 100644 --- a/tests/statement_serializer_tests/base_types.cpp +++ b/tests/statement_serializer_tests/base_types.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/bindables.cpp b/tests/statement_serializer_tests/bindables.cpp index 2f4f59e43..51bd88c3b 100644 --- a/tests/statement_serializer_tests/bindables.cpp +++ b/tests/statement_serializer_tests/bindables.cpp @@ -3,7 +3,7 @@ #include #include // std::fill_n #include -#include +#include using std::array; using std::index_sequence; diff --git a/tests/statement_serializer_tests/collate.cpp b/tests/statement_serializer_tests/collate.cpp index 1887ab70f..df60624f5 100644 --- a/tests/statement_serializer_tests/collate.cpp +++ b/tests/statement_serializer_tests/collate.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/column_constraints/autoincrement.cpp b/tests/statement_serializer_tests/column_constraints/autoincrement.cpp index a80e8f583..08c48cf76 100644 --- a/tests/statement_serializer_tests/column_constraints/autoincrement.cpp +++ b/tests/statement_serializer_tests/column_constraints/autoincrement.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/column_constraints/check.cpp b/tests/statement_serializer_tests/column_constraints/check.cpp index d542b5a0e..b5d892778 100644 --- a/tests/statement_serializer_tests/column_constraints/check.cpp +++ b/tests/statement_serializer_tests/column_constraints/check.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/column_constraints/default.cpp b/tests/statement_serializer_tests/column_constraints/default.cpp index 777b8ac6d..0b78cbdfe 100644 --- a/tests/statement_serializer_tests/column_constraints/default.cpp +++ b/tests/statement_serializer_tests/column_constraints/default.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/column_constraints/generated.cpp b/tests/statement_serializer_tests/column_constraints/generated.cpp index 1684448fc..3bd14d62b 100644 --- a/tests/statement_serializer_tests/column_constraints/generated.cpp +++ b/tests/statement_serializer_tests/column_constraints/generated.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/column_constraints/primary_key.cpp b/tests/statement_serializer_tests/column_constraints/primary_key.cpp index 7a3b511d6..53e5fadf5 100644 --- a/tests/statement_serializer_tests/column_constraints/primary_key.cpp +++ b/tests/statement_serializer_tests/column_constraints/primary_key.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/column_constraints/unique.cpp b/tests/statement_serializer_tests/column_constraints/unique.cpp index c59314c81..a3768c981 100644 --- a/tests/statement_serializer_tests/column_constraints/unique.cpp +++ b/tests/statement_serializer_tests/column_constraints/unique.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/column_names.cpp b/tests/statement_serializer_tests/column_names.cpp index 8509f5cfd..1cc7dc48f 100644 --- a/tests/statement_serializer_tests/column_names.cpp +++ b/tests/statement_serializer_tests/column_names.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/comparison_operators.cpp b/tests/statement_serializer_tests/comparison_operators.cpp index 7724453a9..6b4f41f1e 100644 --- a/tests/statement_serializer_tests/comparison_operators.cpp +++ b/tests/statement_serializer_tests/comparison_operators.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/conditions.cpp b/tests/statement_serializer_tests/conditions.cpp index 8fee838b9..c4376324e 100644 --- a/tests/statement_serializer_tests/conditions.cpp +++ b/tests/statement_serializer_tests/conditions.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/core_functions.cpp b/tests/statement_serializer_tests/core_functions.cpp index 024495b99..85291e33c 100644 --- a/tests/statement_serializer_tests/core_functions.cpp +++ b/tests/statement_serializer_tests/core_functions.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/foreign_key.cpp b/tests/statement_serializer_tests/foreign_key.cpp index efb7f2146..4a938fe99 100644 --- a/tests/statement_serializer_tests/foreign_key.cpp +++ b/tests/statement_serializer_tests/foreign_key.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include // std::is_same diff --git a/tests/statement_serializer_tests/indexed_column.cpp b/tests/statement_serializer_tests/indexed_column.cpp index 8160aee56..2c4955035 100644 --- a/tests/statement_serializer_tests/indexed_column.cpp +++ b/tests/statement_serializer_tests/indexed_column.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/logical_operators.cpp b/tests/statement_serializer_tests/logical_operators.cpp index f3c2f436c..679252b14 100644 --- a/tests/statement_serializer_tests/logical_operators.cpp +++ b/tests/statement_serializer_tests/logical_operators.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/rowid.cpp b/tests/statement_serializer_tests/rowid.cpp index b49196404..8d455cfa7 100644 --- a/tests/statement_serializer_tests/rowid.cpp +++ b/tests/statement_serializer_tests/rowid.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/schema/index.cpp b/tests/statement_serializer_tests/schema/index.cpp index b2a670112..12ebdc3ee 100644 --- a/tests/statement_serializer_tests/schema/index.cpp +++ b/tests/statement_serializer_tests/schema/index.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/schema/new_old.cpp b/tests/statement_serializer_tests/schema/new_old.cpp index 6d4f8e823..fcdf0711c 100644 --- a/tests/statement_serializer_tests/schema/new_old.cpp +++ b/tests/statement_serializer_tests/schema/new_old.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/schema/raise.cpp b/tests/statement_serializer_tests/schema/raise.cpp index 584b5cab4..15430e73a 100644 --- a/tests/statement_serializer_tests/schema/raise.cpp +++ b/tests/statement_serializer_tests/schema/raise.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/schema/trigger.cpp b/tests/statement_serializer_tests/schema/trigger.cpp index e3a5703fb..28c9d00ff 100644 --- a/tests/statement_serializer_tests/schema/trigger.cpp +++ b/tests/statement_serializer_tests/schema/trigger.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/select_constraints.cpp b/tests/statement_serializer_tests/select_constraints.cpp index e473accda..29861b4d6 100644 --- a/tests/statement_serializer_tests/select_constraints.cpp +++ b/tests/statement_serializer_tests/select_constraints.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/statements/insert_replace.cpp b/tests/statement_serializer_tests/statements/insert_replace.cpp index 400616625..c5eb90b30 100644 --- a/tests/statement_serializer_tests/statements/insert_replace.cpp +++ b/tests/statement_serializer_tests/statements/insert_replace.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/statements/remove.cpp b/tests/statement_serializer_tests/statements/remove.cpp index b30b00d7f..06a1f6623 100644 --- a/tests/statement_serializer_tests/statements/remove.cpp +++ b/tests/statement_serializer_tests/statements/remove.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/statements/remove_all.cpp b/tests/statement_serializer_tests/statements/remove_all.cpp index 34403a4e5..aeb2ba408 100644 --- a/tests/statement_serializer_tests/statements/remove_all.cpp +++ b/tests/statement_serializer_tests/statements/remove_all.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/statements/select.cpp b/tests/statement_serializer_tests/statements/select.cpp index b5f09c87c..efe7a1096 100644 --- a/tests/statement_serializer_tests/statements/select.cpp +++ b/tests/statement_serializer_tests/statements/select.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/statements/update.cpp b/tests/statement_serializer_tests/statements/update.cpp index 3cf3105dd..3dc87dfc1 100644 --- a/tests/statement_serializer_tests/statements/update.cpp +++ b/tests/statement_serializer_tests/statements/update.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/statement_serializer_tests/statements/update_all.cpp b/tests/statement_serializer_tests/statements/update_all.cpp index 67164e040..6931a5a85 100644 --- a/tests/statement_serializer_tests/statements/update_all.cpp +++ b/tests/statement_serializer_tests/statements/update_all.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/static_tests/aggregate_function_return_types.cpp b/tests/static_tests/aggregate_function_return_types.cpp index 4ecfa97b8..ff5ed9208 100644 --- a/tests/static_tests/aggregate_function_return_types.cpp +++ b/tests/static_tests/aggregate_function_return_types.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include // std::is_same using namespace sqlite_orm; diff --git a/tests/static_tests/arithmetic_operators_result_type.cpp b/tests/static_tests/arithmetic_operators_result_type.cpp index 30642c54e..4fc246735 100644 --- a/tests/static_tests/arithmetic_operators_result_type.cpp +++ b/tests/static_tests/arithmetic_operators_result_type.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include // std::is_same using namespace sqlite_orm; diff --git a/tests/static_tests/bindable_filter.cpp b/tests/static_tests/bindable_filter.cpp index a58676f02..afaff9f96 100644 --- a/tests/static_tests/bindable_filter.cpp +++ b/tests/static_tests/bindable_filter.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include // std::is_same #ifdef SQLITE_ORM_OPTIONAL_SUPPORTED #include diff --git a/tests/static_tests/column.cpp b/tests/static_tests/column.cpp index e50b1ffc0..40de6965d 100644 --- a/tests/static_tests/column.cpp +++ b/tests/static_tests/column.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "static_tests_common.h" diff --git a/tests/static_tests/column_result_t.cpp b/tests/static_tests/column_result_t.cpp index 0a20ceb8b..d933a13d7 100644 --- a/tests/static_tests/column_result_t.cpp +++ b/tests/static_tests/column_result_t.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include // std::is_same using namespace sqlite_orm; diff --git a/tests/static_tests/compound_operators.cpp b/tests/static_tests/compound_operators.cpp index 0b761d3c2..164502e3b 100644 --- a/tests/static_tests/compound_operators.cpp +++ b/tests/static_tests/compound_operators.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "static_tests_common.h" diff --git a/tests/static_tests/core_function_return_types.cpp b/tests/static_tests/core_function_return_types.cpp index a3d8c9de7..333bc30b4 100644 --- a/tests/static_tests/core_function_return_types.cpp +++ b/tests/static_tests/core_function_return_types.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include // std::is_same #include // nullptr_t diff --git a/tests/static_tests/foreign_key.cpp b/tests/static_tests/foreign_key.cpp index 3804f1c44..60ed3fe8a 100644 --- a/tests/static_tests/foreign_key.cpp +++ b/tests/static_tests/foreign_key.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include // std::is_same #include // std::string diff --git a/tests/static_tests/function_static_tests.cpp b/tests/static_tests/function_static_tests.cpp index 44790b948..a3989631a 100644 --- a/tests/static_tests/function_static_tests.cpp +++ b/tests/static_tests/function_static_tests.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include // std::is_same using namespace sqlite_orm; diff --git a/tests/static_tests/functional/mpl.cpp b/tests/static_tests/functional/mpl.cpp index 00fbaea4a..928238547 100644 --- a/tests/static_tests/functional/mpl.cpp +++ b/tests/static_tests/functional/mpl.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/static_tests/functional/same_or_void.cpp b/tests/static_tests/functional/same_or_void.cpp index 4bc6b53db..1f58d4a1d 100644 --- a/tests/static_tests/functional/same_or_void.cpp +++ b/tests/static_tests/functional/same_or_void.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include // std::is_same #include // std::string diff --git a/tests/static_tests/functional/static_if_tests.cpp b/tests/static_tests/functional/static_if_tests.cpp index 19b7f0ab7..e9157337b 100644 --- a/tests/static_tests/functional/static_if_tests.cpp +++ b/tests/static_tests/functional/static_if_tests.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; using internal::call_if_constexpr; diff --git a/tests/static_tests/functional/tuple_conc.cpp b/tests/static_tests/functional/tuple_conc.cpp index f55f5bea4..7291c6d92 100644 --- a/tests/static_tests/functional/tuple_conc.cpp +++ b/tests/static_tests/functional/tuple_conc.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include // std::string #include // std::is_same diff --git a/tests/static_tests/functional/tuple_filter.cpp b/tests/static_tests/functional/tuple_filter.cpp index 552c8c122..16c16107f 100644 --- a/tests/static_tests/functional/tuple_filter.cpp +++ b/tests/static_tests/functional/tuple_filter.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include // std::is_same using namespace sqlite_orm; diff --git a/tests/static_tests/functional/tuple_traits.cpp b/tests/static_tests/functional/tuple_traits.cpp index f8690170b..d11d43a7f 100644 --- a/tests/static_tests/functional/tuple_traits.cpp +++ b/tests/static_tests/functional/tuple_traits.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; using internal::check_if_tuple_has; diff --git a/tests/static_tests/functional/tuple_transform.cpp b/tests/static_tests/functional/tuple_transform.cpp index ad75f6455..d2f61788f 100644 --- a/tests/static_tests/functional/tuple_transform.cpp +++ b/tests/static_tests/functional/tuple_transform.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include // std::is_same using namespace sqlite_orm; diff --git a/tests/static_tests/is_bindable.cpp b/tests/static_tests/is_bindable.cpp index 1bd3fde44..d9d054e97 100644 --- a/tests/static_tests/is_bindable.cpp +++ b/tests/static_tests/is_bindable.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include // std::unique_ptr, std::shared_ptr #include // std::string #ifdef SQLITE_ORM_OPTIONAL_SUPPORTED diff --git a/tests/static_tests/is_column_with_insertable_primary_key.cpp b/tests/static_tests/is_column_with_insertable_primary_key.cpp index 24ee04392..4be302d29 100644 --- a/tests/static_tests/is_column_with_insertable_primary_key.cpp +++ b/tests/static_tests/is_column_with_insertable_primary_key.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; using namespace internal; diff --git a/tests/static_tests/is_primary_key_insertable.cpp b/tests/static_tests/is_primary_key_insertable.cpp index 4d5143a54..274b0a4c8 100644 --- a/tests/static_tests/is_primary_key_insertable.cpp +++ b/tests/static_tests/is_primary_key_insertable.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include // std::std::decay using namespace sqlite_orm; diff --git a/tests/static_tests/is_printable.cpp b/tests/static_tests/is_printable.cpp index 8b3a3d4e4..86d7ef9a4 100644 --- a/tests/static_tests/is_printable.cpp +++ b/tests/static_tests/is_printable.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include // std::unique_ptr, std::shared_ptr #include // std::string #ifdef SQLITE_ORM_OPTIONAL_SUPPORTED diff --git a/tests/static_tests/iterator_t.cpp b/tests/static_tests/iterator_t.cpp index 496e9aff3..39c424dc4 100644 --- a/tests/static_tests/iterator_t.cpp +++ b/tests/static_tests/iterator_t.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include using namespace sqlite_orm; diff --git a/tests/static_tests/member_traits_tests.cpp b/tests/static_tests/member_traits_tests.cpp index 2e24a31fb..be1ed63f2 100644 --- a/tests/static_tests/member_traits_tests.cpp +++ b/tests/static_tests/member_traits_tests.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/static_tests/node_tuple.cpp b/tests/static_tests/node_tuple.cpp index c0dca0a4b..7b4fadfe9 100644 --- a/tests/static_tests/node_tuple.cpp +++ b/tests/static_tests/node_tuple.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include // std::is_same using namespace sqlite_orm; diff --git a/tests/static_tests/select_return_type.cpp b/tests/static_tests/select_return_type.cpp index decbf5683..86d40e5c9 100644 --- a/tests/static_tests/select_return_type.cpp +++ b/tests/static_tests/select_return_type.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "static_tests_common.h" #include "static_tests_storage_traits.h" diff --git a/tests/storage_non_crud_tests.cpp b/tests/storage_non_crud_tests.cpp index 30b412fae..aab36cd62 100644 --- a/tests/storage_non_crud_tests.cpp +++ b/tests/storage_non_crud_tests.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; @@ -498,7 +498,7 @@ TEST_CASE("Remove all") { } TEST_CASE("Explicit insert") { - using Catch::Matchers::Contains; + using Catch::Matchers::ContainsSubstring; struct User { int id; @@ -587,7 +587,7 @@ TEST_CASE("Explicit insert") { SECTION("one column") { User user4; user4.name = "Egor"; - REQUIRE_THROWS_WITH(storage.insert(user4, columns(&User::name)), Contains("NOT NULL constraint failed")); + REQUIRE_THROWS_WITH(storage.insert(user4, columns(&User::name)), ContainsSubstring("NOT NULL constraint failed")); } } SECTION("visit") { @@ -620,7 +620,7 @@ TEST_CASE("Explicit insert") { visit3.setId(10); SECTION("getter") { REQUIRE_THROWS_WITH(storage.insert(visit3, columns(&Visit::id)), - Contains("NOT NULL constraint failed")); + ContainsSubstring("NOT NULL constraint failed")); } } } diff --git a/tests/storage_tests.cpp b/tests/storage_tests.cpp index eb4c319af..e1feeb49b 100644 --- a/tests/storage_tests.cpp +++ b/tests/storage_tests.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/sync_schema_tests.cpp b/tests/sync_schema_tests.cpp index b89ad5292..7ec68d229 100644 --- a/tests/sync_schema_tests.cpp +++ b/tests/sync_schema_tests.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include using namespace sqlite_orm; diff --git a/tests/table_tests.cpp b/tests/table_tests.cpp index d9e9dc39e..d36e5e8dc 100644 --- a/tests/table_tests.cpp +++ b/tests/table_tests.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/tests.cpp b/tests/tests.cpp index b53f84262..d0e13dc57 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -1,8 +1,5 @@ #include - -#define CATCH_CONFIG_MAIN - -#include +#include #include // std::vector #include // std::string @@ -107,7 +104,7 @@ TEST_CASE("Limits") { } TEST_CASE("Custom collate") { - using Catch::Matchers::Contains; + using Catch::Matchers::ContainsSubstring; struct Item { int id; @@ -193,11 +190,11 @@ TEST_CASE("Custom collate") { storage.delete_collation(); } REQUIRE_THROWS_WITH(storage.select(&Item::name, where(is_equal(&Item::name, "Mercury").collate("ototo"))), - Contains("no such collation sequence")); + ContainsSubstring("no such collation sequence")); REQUIRE_THROWS_WITH(storage.select(&Item::name, where(is_equal(&Item::name, "Mercury").collate())), - Contains("no such collation sequence")); + ContainsSubstring("no such collation sequence")); REQUIRE_THROWS_WITH(storage.select(&Item::name, where(is_equal(&Item::name, "Mercury").collate("ototo2"))), - Contains("no such collation sequence")); + ContainsSubstring("no such collation sequence")); rows = storage.select(&Item::name, where(is_equal(&Item::name, "Mercury").collate("alwaysequal")), diff --git a/tests/tests2.cpp b/tests/tests2.cpp index 59e83f44b..2ae6a1ece 100644 --- a/tests/tests2.cpp +++ b/tests/tests2.cpp @@ -1,5 +1,5 @@ #include -#include +#include #ifdef SQLITE_ORM_OPTIONAL_SUPPORTED #include // std::optional #endif // SQLITE_ORM_OPTIONAL_SUPPORTED @@ -357,7 +357,7 @@ int FirstFunction::objectsCount = 0; int FirstFunction::callsCount = 0; TEST_CASE("custom functions") { - using Catch::Matchers::Contains; + using Catch::Matchers::ContainsSubstring; SqrtFunction::callsCount = 0; HasPrefixFunction::callsCount = 0; @@ -382,7 +382,7 @@ TEST_CASE("custom functions") { auto storage = make_storage(path, make_table("users", make_column("id", &User::id))); storage.sync_schema(); // call before creation - REQUIRE_THROWS_WITH(storage.select(func(4)), Contains("no such function")); + REQUIRE_THROWS_WITH(storage.select(func(4)), ContainsSubstring("no such function")); // create function REQUIRE(SqrtFunction::callsCount == 0); diff --git a/tests/tests3.cpp b/tests/tests3.cpp index 3d8aa2295..2f945fa69 100644 --- a/tests/tests3.cpp +++ b/tests/tests3.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/tests4.cpp b/tests/tests4.cpp index 1da0b924a..9a72a9f7e 100644 --- a/tests/tests4.cpp +++ b/tests/tests4.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include // std::count_if #ifdef SQLITE_ORM_OPTIONAL_SUPPORTED #include // std::optional diff --git a/tests/tests5.cpp b/tests/tests5.cpp index 79da9bba0..fc683d186 100644 --- a/tests/tests5.cpp +++ b/tests/tests5.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include // std::iota using namespace sqlite_orm; diff --git a/tests/transaction_tests.cpp b/tests/transaction_tests.cpp index 905288f5a..adf9792f8 100644 --- a/tests/transaction_tests.cpp +++ b/tests/transaction_tests.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; @@ -189,7 +189,7 @@ TEST_CASE("Transaction guard") { REQUIRE(storage.count() == countBefore); } SECTION("exception propagated from dtor") { - using namespace Catch::Matchers; + using Catch::Matchers::ContainsSubstring; // create a second database connection auto storage2 = make_storage("guard.sqlite", table); @@ -200,7 +200,7 @@ TEST_CASE("Transaction guard") { auto guard = new(&buffer) internal::transaction_guard_t{storage.transaction_guard()}; storage.insert({}); guard->commit_on_destroy = true; - REQUIRE_THROWS_WITH(guard->~transaction_guard_t(), Contains("database is locked")); + REQUIRE_THROWS_WITH(guard->~transaction_guard_t(), ContainsSubstring("database is locked")); } ::remove("guard.sqlite"); } diff --git a/tests/trigger_tests.cpp b/tests/trigger_tests.cpp index 9a4866ceb..36d6a7de3 100644 --- a/tests/trigger_tests.cpp +++ b/tests/trigger_tests.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/tuple_iteration.cpp b/tests/tuple_iteration.cpp index aa8be2866..95d916250 100644 --- a/tests/tuple_iteration.cpp +++ b/tests/tuple_iteration.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include // std::type_index #include // std::string #include // std::remove_pointer diff --git a/tests/unique_cases/delete_with_two_fields.cpp b/tests/unique_cases/delete_with_two_fields.cpp index 0d91fc9ce..558bd3e17 100644 --- a/tests/unique_cases/delete_with_two_fields.cpp +++ b/tests/unique_cases/delete_with_two_fields.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/unique_cases/get_all_with_two_tables.cpp b/tests/unique_cases/get_all_with_two_tables.cpp index bdda88172..f0eb715f3 100644 --- a/tests/unique_cases/get_all_with_two_tables.cpp +++ b/tests/unique_cases/get_all_with_two_tables.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/unique_cases/index_named_table_with_fk.cpp b/tests/unique_cases/index_named_table_with_fk.cpp index 3ebd8183e..7d3b18edb 100644 --- a/tests/unique_cases/index_named_table_with_fk.cpp +++ b/tests/unique_cases/index_named_table_with_fk.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/unique_cases/issue525.cpp b/tests/unique_cases/issue525.cpp index 62f7ae8c8..1b71e02b7 100644 --- a/tests/unique_cases/issue525.cpp +++ b/tests/unique_cases/issue525.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/unique_cases/issue663.cpp b/tests/unique_cases/issue663.cpp index 565251893..b4ab6135d 100644 --- a/tests/unique_cases/issue663.cpp +++ b/tests/unique_cases/issue663.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/unique_cases/issue86.cpp b/tests/unique_cases/issue86.cpp index e4ad92b14..ddae77874 100644 --- a/tests/unique_cases/issue86.cpp +++ b/tests/unique_cases/issue86.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/unique_cases/issue937.cpp b/tests/unique_cases/issue937.cpp index ed1dc3cf4..51ece11b5 100644 --- a/tests/unique_cases/issue937.cpp +++ b/tests/unique_cases/issue937.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; #ifdef SQLITE_ORM_OPTIONAL_SUPPORTED diff --git a/tests/unique_cases/join_iterator_ctor_compilation_error.cpp b/tests/unique_cases/join_iterator_ctor_compilation_error.cpp index cbbb947e0..03d4e02b5 100644 --- a/tests/unique_cases/join_iterator_ctor_compilation_error.cpp +++ b/tests/unique_cases/join_iterator_ctor_compilation_error.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; diff --git a/tests/unique_cases/prepare_get_all_with_case.cpp b/tests/unique_cases/prepare_get_all_with_case.cpp index 034fe4f32..1633a0f5d 100644 --- a/tests/unique_cases/prepare_get_all_with_case.cpp +++ b/tests/unique_cases/prepare_get_all_with_case.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace sqlite_orm; From 8e9625e2ea774493f451f2cd9980e44088271727 Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Sun, 15 Jan 2023 22:17:19 +0200 Subject: [PATCH 05/22] Fixed availability of chrono binding example --- examples/chrono_binding.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/examples/chrono_binding.cpp b/examples/chrono_binding.cpp index 6100df710..81538ae45 100644 --- a/examples/chrono_binding.cpp +++ b/examples/chrono_binding.cpp @@ -6,6 +6,10 @@ #include #if __cpp_lib_chrono >= 201907L && __cpp_lib_format >= 201907L +#define ENABLE_THIS_EXAMPLE +#endif + +#ifdef ENABLE_THIS_EXAMPLE /////////////////////////////// /// sys_days binding as TEXT @@ -14,11 +18,6 @@ #include #include -static std::chrono::sys_days today() { - const auto today = std::chrono::sys_days{floor(std::chrono::system_clock::now())}; - return today; -} - /** * This is the date we want to map to our sqlite db. * Let's make it `TEXT` @@ -143,10 +142,10 @@ struct Person { std::string name; std::chrono::sys_days birthdate; }; +#endif -int main(int argc, const char* argv[]) { - cout << argv[0] << endl; - +int main(int, char**) { +#ifdef ENABLE_THIS_EXAMPLE const std::string db_name = "sys_days.sqlite"; ::remove(db_name.c_str()); @@ -168,6 +167,5 @@ int main(int argc, const char* argv[]) { auto pers = storage.get(1); year_month_day ymd = pers.birthdate; // using the implicit operator from sys_days to year_month_day assert(ymd == birthdate); -} - #endif +} From 5330ecdf6619ba0d9ca25b0dbb046333030acb55 Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Sun, 15 Jan 2023 23:11:19 +0200 Subject: [PATCH 06/22] Corrected appveyor vcpkg initialization --- appveyor.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 205cadb12..13a520740 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -96,17 +96,15 @@ for: if "%appveyor_build_worker_image%"=="Visual Studio 2015" (set generator="Visual Studio 14 2015" %architecture%) install: - |- - cd C:\Tools\vcpkg git clone --depth 1 --branch 2023.01.09 https://github.com/microsoft/vcpkg.git "$HOME/vcpkg" - .\bootstrap-vcpkg.bat - cd "%APPVEYOR_BUILD_FOLDER%" + C:\Tools\vcpkg\bootstrap-vcpkg.bat C:\Tools\vcpkg\vcpkg integrate install vcpkg install sqlite3:%platform%-windows before_build: - |- mkdir compile cd compile - cmake %SQLITE_ORM_CXX_STANDARD% -DSqliteOrm_BuildTests=ON .. -G %generator% -DCMAKE_TOOLCHAIN_FILE=C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake + cmake %SQLITE_ORM_CXX_STANDARD% .. -G %generator% -DCMAKE_TOOLCHAIN_FILE=C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake # build examples, and run tests (ie make & make test) build_script: - |- @@ -126,14 +124,14 @@ for: install: - |- git clone --depth 1 --branch 2023.01.09 https://github.com/microsoft/vcpkg.git $HOME/vcpkg - $HOME/vcpkg/booststrap.sh + $HOME/vcpkg/bootstrap-vcpkg.sh $HOME/vcpkg/vcpkg integrate install --overlay-triplets=vcpkg/triplets vcpkg install sqlite3 --overlay-triplets=vcpkg/triplets before_build: - |- mkdir compile cd compile - cmake $SQLITE_ORM_CXX_STANDARD -DSqliteOrm_BuildTests=ON .. -DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake + cmake $SQLITE_ORM_CXX_STANDARD .. -DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake # build examples, and run tests (ie make & make test) build_script: - |- @@ -152,14 +150,14 @@ for: install: - |- git clone --depth 1 --branch 2023.01.09 https://github.com/microsoft/vcpkg.git $HOME/vcpkg - $HOME/vcpkg/booststrap.sh + $HOME/vcpkg/bootstrap-vcpkg.sh $HOME/vcpkg/vcpkg integrate install --overlay-triplets=vcpkg/triplets vcpkg install sqlite3 --overlay-triplets=vcpkg/triplets before_build: - |- mkdir compile cd compile - cmake $SQLITE_ORM_CXX_STANDARD -DSqliteOrm_BuildTests=ON .. -DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake + cmake $SQLITE_ORM_CXX_STANDARD .. -DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake # build examples, and run tests (ie make & make test) build_script: - |- From a0acab79d536f23f07356211f61d8659f03e2256 Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Mon, 16 Jan 2023 10:02:01 +0200 Subject: [PATCH 07/22] Turned `type_is_nullable` into a specializable struct again --- dev/storage.h | 2 +- dev/type_is_nullable.h | 24 +- dev/xdestroy_handling.h | 35 +-- examples/nullable_enum_binding.cpp | 2 +- include/sqlite_orm/sqlite_orm.h | 381 ++++++++++++++++++++--------- 5 files changed, 315 insertions(+), 129 deletions(-) diff --git a/dev/storage.h b/dev/storage.h index 33f37cdb8..1d5a53563 100644 --- a/dev/storage.h +++ b/dev/storage.h @@ -586,7 +586,7 @@ namespace sqlite_orm { static_assert(is_preparable_v, "Expression must be a high-level statement"); decltype(auto) e2 = static_if>( - [](auto expression) -> auto { + [](auto expression) -> auto{ expression.highest_level = true; return expression; }, diff --git a/dev/type_is_nullable.h b/dev/type_is_nullable.h index a88b42b1c..1f77b95cf 100644 --- a/dev/type_is_nullable.h +++ b/dev/type_is_nullable.h @@ -1,5 +1,6 @@ #pragma once +#include // std::false_type, std::true_type, std::enable_if #include // std::shared_ptr, std::unique_ptr #include "functional/cxx_optional.h" @@ -14,12 +15,27 @@ namespace sqlite_orm { * custom type as `NULL` (for example: boost::optional) you have to create a specialiation * of type_is_nullable for your type and derive from `std::true_type`. */ + template + struct type_is_nullable : std::false_type { + bool operator()(const T&) const { + return true; + } + }; + + /** + * This is a specialization for std::shared_ptr, std::unique_ptr, std::optional, which are nullable in sqlite_orm. + */ template - using type_is_nullable = polyfill::disjunction< + struct type_is_nullable, + polyfill::is_specialization_of, #endif - polyfill::is_specialization_of, - polyfill::is_specialization_of>; + polyfill::is_specialization_of, + polyfill::is_specialization_of>>> : std::true_type { + bool operator()(const T& t) const { + return static_cast(t); + } + }; } diff --git a/dev/xdestroy_handling.h b/dev/xdestroy_handling.h index e9f986a03..25e172a32 100644 --- a/dev/xdestroy_handling.h +++ b/dev/xdestroy_handling.h @@ -29,20 +29,20 @@ namespace sqlite_orm { */ template concept integral_fp_c = requires { - typename D::value_type; - D::value; - requires std::is_function_v>; - }; + typename D::value_type; + D::value; + requires std::is_function_v>; + }; /** * Constraints a deleter to be or to yield a function pointer. */ template concept yields_fp = requires(D d) { - // yielding function pointer by using the plus trick - {+d}; - requires std::is_function_v>; - }; + // yielding function pointer by using the plus trick + { +d }; + requires std::is_function_v>; + }; #endif #if __cpp_lib_concepts >= 201907L @@ -57,7 +57,7 @@ namespace sqlite_orm { template SQLITE_ORM_INLINE_VAR constexpr bool is_stateless_deleter_v = - std::is_empty::value&& std::is_default_constructible::value; + std::is_empty::value && std::is_default_constructible::value; template struct is_integral_fp_c : std::false_type {}; @@ -118,7 +118,8 @@ namespace sqlite_orm { * it doesn't check so explicitly, but a compiler error will occur. */ template - requires(!integral_fp_c) void xdestroy_proxy(void* p) noexcept { + requires(!integral_fp_c) + void xdestroy_proxy(void* p) noexcept { // C-casting `void* -> P*` like statement_binder> auto o = (P*)p; // ignoring return code @@ -146,7 +147,7 @@ namespace sqlite_orm { template SQLITE_ORM_INLINE_VAR constexpr bool can_yield_xdestroy_v = - can_yield_fp_v&& std::is_convertible, xdestroy_fn_t>::value; + can_yield_fp_v && std::is_convertible, xdestroy_fn_t>::value; template SQLITE_ORM_INLINE_VAR constexpr bool needs_xdestroy_proxy_v = @@ -181,7 +182,9 @@ namespace sqlite_orm { * Explicitly declared for better error messages. */ template - constexpr xdestroy_fn_t obtain_xdestroy_for(D, P*) noexcept requires(internal::is_unusable_for_xdestroy) { + constexpr xdestroy_fn_t obtain_xdestroy_for(D, P*) noexcept + requires(internal::is_unusable_for_xdestroy) + { static_assert(polyfill::always_false_v, "A function pointer, which is not of type xdestroy_fn_t, is prohibited."); return nullptr; @@ -200,7 +203,9 @@ namespace sqlite_orm { * is invocable with the non-q-qualified pointer value. */ template - constexpr xdestroy_fn_t obtain_xdestroy_for(D, P*) noexcept requires(internal::needs_xdestroy_proxy) { + constexpr xdestroy_fn_t obtain_xdestroy_for(D, P*) noexcept + requires(internal::needs_xdestroy_proxy) + { return internal::xdestroy_proxy; } @@ -219,7 +224,9 @@ namespace sqlite_orm { * is invocable with the non-q-qualified pointer value. */ template - constexpr xdestroy_fn_t obtain_xdestroy_for(D d, P*) noexcept requires(internal::yields_xdestroy) { + constexpr xdestroy_fn_t obtain_xdestroy_for(D d, P*) noexcept + requires(internal::yields_xdestroy) + { return d; } #else diff --git a/examples/nullable_enum_binding.cpp b/examples/nullable_enum_binding.cpp index 46d360cc8..8625af059 100644 --- a/examples/nullable_enum_binding.cpp +++ b/examples/nullable_enum_binding.cpp @@ -99,7 +99,7 @@ namespace sqlite_orm { * specializing type_is_nullable and deriving from std::true_type. */ template<> - struct type_is_nullable : public std::true_type { + struct type_is_nullable : std::true_type { // this function must return whether value null or not (false is null). Don't forget to implement it bool operator()(const Gender& g) const { diff --git a/include/sqlite_orm/sqlite_orm.h b/include/sqlite_orm/sqlite_orm.h index 3ead3a346..56022ee29 100644 --- a/include/sqlite_orm/sqlite_orm.h +++ b/include/sqlite_orm/sqlite_orm.h @@ -16,6 +16,7 @@ __pragma(push_macro("max")) // #include "cxx_universal.h" + /* * This header makes central C++ functionality on which sqlite_orm depends universally available: * - alternative operator representations @@ -34,6 +35,7 @@ using std::nullptr_t; // #include "cxx_core_features.h" + #ifdef __has_cpp_attribute #define SQLITE_ORM_HAS_CPP_ATTRIBUTE(attr) __has_cpp_attribute(attr) #else @@ -107,6 +109,7 @@ using std::nullptr_t; // #include "cxx_compiler_quirks.h" + #ifdef __clang__ #define SQLITE_ORM_DO_PRAGMA(...) _Pragma(#__VA_ARGS__) #endif @@ -136,6 +139,8 @@ using std::nullptr_t; #define SQLITE_ORM_BROKEN_VARIADIC_PACK_EXPANSION #endif + + namespace sqlite_orm { namespace internal { namespace polyfill { @@ -277,6 +282,7 @@ namespace sqlite_orm { namespace polyfill = internal::polyfill; } + namespace sqlite_orm { // C++ generic traits used throughout the library namespace internal { @@ -505,8 +511,10 @@ namespace sqlite_orm { #include // std::vector // #include "functional/cxx_optional.h" + // #include "cxx_core_features.h" + #if SQLITE_ORM_HAS_INCLUDE() #include #endif @@ -515,6 +523,7 @@ namespace sqlite_orm { #define SQLITE_ORM_OPTIONAL_SUPPORTED #endif + // #include "functional/cxx_type_traits_polyfill.h" // #include "type_traits.h" @@ -551,6 +560,7 @@ namespace sqlite_orm { }; } + namespace sqlite_orm { /** @@ -649,6 +659,7 @@ namespace sqlite_orm { // #include "functional/mpl.h" + /* * Symbols for 'template metaprogramming' (compile-time template programming), * inspired by the MPL of Aleksey Gurtovoy and David Abrahams. @@ -677,6 +688,7 @@ namespace sqlite_orm { // #include "cxx_type_traits_polyfill.h" + namespace sqlite_orm { namespace internal { namespace mpl { @@ -957,6 +969,7 @@ namespace sqlite_orm { // #include "tuple_helper/same_or_void.h" + namespace sqlite_orm { namespace internal { @@ -986,6 +999,7 @@ namespace sqlite_orm { // #include "tuple_helper/tuple_traits.h" + #include // std::is_same #include @@ -993,6 +1007,7 @@ namespace sqlite_orm { // #include "../functional/mpl.h" + namespace sqlite_orm { namespace internal { /* @@ -1040,6 +1055,7 @@ namespace sqlite_orm { } // #include "tuple_helper/tuple_filter.h" + #include // std::integral_constant, std::index_sequence, std::conditional, std::declval #include // std::tuple @@ -1047,6 +1063,7 @@ namespace sqlite_orm { // #include "../functional/index_sequence_util.h" + #include // std::index_sequence, std::make_index_sequence // #include "../functional/cxx_universal.h" @@ -1115,6 +1132,7 @@ namespace sqlite_orm { } } + namespace sqlite_orm { namespace internal { @@ -1206,6 +1224,7 @@ namespace sqlite_orm { // #include "table_type_of.h" + namespace sqlite_orm { namespace internal { @@ -1242,6 +1261,7 @@ namespace sqlite_orm { // #include "type_printer.h" + namespace sqlite_orm { namespace internal { @@ -1784,11 +1804,14 @@ namespace sqlite_orm { } #pragma once +#include // std::false_type, std::true_type, std::enable_if #include // std::shared_ptr, std::unique_ptr // #include "functional/cxx_optional.h" + // #include "functional/cxx_type_traits_polyfill.h" + namespace sqlite_orm { /** @@ -1798,13 +1821,28 @@ namespace sqlite_orm { * custom type as `NULL` (for example: boost::optional) you have to create a specialiation * of type_is_nullable for your type and derive from `std::true_type`. */ + template + struct type_is_nullable : std::false_type { + bool operator()(const T&) const { + return true; + } + }; + + /** + * This is a specialization for std::shared_ptr, std::unique_ptr, std::optional, which are nullable in sqlite_orm. + */ template - using type_is_nullable = polyfill::disjunction< + struct type_is_nullable, + polyfill::is_specialization_of, #endif - polyfill::is_specialization_of, - polyfill::is_specialization_of>; + polyfill::is_specialization_of, + polyfill::is_specialization_of>>> : std::true_type { + bool operator()(const T& t) const { + return static_cast(t); + } + }; } #pragma once @@ -1813,8 +1851,10 @@ namespace sqlite_orm { #include // std::move // #include "functional/cxx_optional.h" + // #include "tags.h" + namespace sqlite_orm { namespace internal { struct negatable_t {}; @@ -1828,10 +1868,13 @@ namespace sqlite_orm { // #include "serialize_result_type.h" + // #include "functional/cxx_string_view.h" + // #include "cxx_core_features.h" + #if SQLITE_ORM_HAS_INCLUDE() #include #endif @@ -1854,6 +1897,7 @@ namespace sqlite_orm { } } + namespace sqlite_orm { namespace internal { @@ -2142,12 +2186,14 @@ namespace sqlite_orm { // #include "member_traits/member_traits.h" + #include // std::enable_if, std::is_function, std::true_type, std::false_type // #include "../functional/cxx_universal.h" // #include "../functional/cxx_type_traits_polyfill.h" + namespace sqlite_orm { namespace internal { // SFINAE friendly trait to get a member object pointer's field type @@ -2239,6 +2285,7 @@ namespace sqlite_orm { // #include "constraints.h" + namespace sqlite_orm { namespace internal { @@ -2417,12 +2464,14 @@ namespace sqlite_orm { #endif // SQLITE_ORM_OMITS_CODECVT // #include "functional/cxx_optional.h" + // #include "functional/cxx_universal.h" // #include "functional/cxx_type_traits_polyfill.h" // #include "is_std_ptr.h" + namespace sqlite_orm { /** @@ -2586,6 +2635,7 @@ namespace sqlite_orm { // #include "optional_container.h" + namespace sqlite_orm { namespace internal { @@ -2620,6 +2670,7 @@ namespace sqlite_orm { // #include "serializer_context.h" + namespace sqlite_orm { namespace internal { @@ -2661,14 +2712,17 @@ namespace sqlite_orm { // #include "expression.h" + #include #include // std::move, std::forward // #include "functional/cxx_optional.h" + // #include "functional/cxx_universal.h" // #include "operators.h" + namespace sqlite_orm { namespace internal { @@ -2747,6 +2801,7 @@ namespace sqlite_orm { // #include "literal.h" + namespace sqlite_orm { namespace internal { @@ -2763,6 +2818,7 @@ namespace sqlite_orm { } } + namespace sqlite_orm { namespace internal { @@ -4180,6 +4236,7 @@ namespace sqlite_orm { // #include "conditions.h" + namespace sqlite_orm { namespace internal { @@ -4293,6 +4350,7 @@ namespace sqlite_orm { // #include "is_base_of_template.h" + #include // std::true_type, std::false_type, std::declval namespace sqlite_orm { @@ -4338,8 +4396,10 @@ namespace sqlite_orm { // #include "ast/into.h" + // #include "../functional/cxx_type_traits_polyfill.h" + namespace sqlite_orm { namespace internal { @@ -4358,6 +4418,7 @@ namespace sqlite_orm { } } + namespace sqlite_orm { using int64 = sqlite_int64; @@ -6461,6 +6522,7 @@ namespace sqlite_orm { #include // std::tuple, std::get, std::tuple_size // #include "functional/cxx_optional.h" + // #include "functional/cxx_universal.h" // #include "functional/cxx_type_traits_polyfill.h" @@ -6473,6 +6535,7 @@ namespace sqlite_orm { // #include "ast/where.h" + #include // std::false_type, std::true_type #include // std::move @@ -6482,6 +6545,7 @@ namespace sqlite_orm { // #include "../serialize_result_type.h" + namespace sqlite_orm { namespace internal { @@ -6529,12 +6593,14 @@ namespace sqlite_orm { // #include "ast/group_by.h" + #include // std::tuple, std::make_tuple #include // std::true_type, std::false_type #include // std::forward, std::move // #include "../functional/cxx_type_traits_polyfill.h" + namespace sqlite_orm { namespace internal { @@ -6604,6 +6670,7 @@ namespace sqlite_orm { // #include "core_functions.h" + namespace sqlite_orm { namespace internal { @@ -7080,6 +7147,7 @@ namespace sqlite_orm { // #include "functional/cxx_universal.h" + namespace sqlite_orm { struct table_info { @@ -7136,6 +7204,7 @@ namespace sqlite_orm { // #include "optional_container.h" + // NOTE Idea : Maybe also implement a custom trigger system to call a c++ callback when a trigger triggers ? // (Could be implemented with a normal trigger that insert or update an internal table and then retreive // the event in the C++ code, to call the C++ user callback, with update hooks: https://www.sqlite.org/c3ref/update_hook.html) @@ -7168,7 +7237,7 @@ namespace sqlite_orm { partial_trigger_t(T trigger_base, S... statements) : base{std::move(trigger_base)}, statements{std::make_tuple(std::forward(statements)...)} {} - partial_trigger_t& end() { + partial_trigger_t &end() { return *this; } }; @@ -7237,7 +7306,7 @@ namespace sqlite_orm { trigger_base_t(trigger_type_base type_base_) : type_base(std::move(type_base_)) {} - trigger_base_t& for_each_row() { + trigger_base_t &for_each_row() { this->do_for_each_row = true; return *this; } @@ -7398,7 +7467,7 @@ namespace sqlite_orm { } template - internal::trigger_t make_trigger(std::string name, const internal::partial_trigger_t& part) { + internal::trigger_t make_trigger(std::string name, const internal::partial_trigger_t &part) { SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(return {move(name), std::move(part.base), std::move(part.statements)}); } @@ -7458,6 +7527,7 @@ namespace sqlite_orm { // #include "xdestroy_handling.h" + #include // std::integral_constant #if defined(SQLITE_ORM_CONCEPTS_SUPPORTED) && SQLITE_ORM_HAS_INCLUDE() #include @@ -7467,6 +7537,7 @@ namespace sqlite_orm { // #include "functional/cxx_type_traits_polyfill.h" + namespace sqlite_orm { using xdestroy_fn_t = void (*)(void*); @@ -7488,20 +7559,20 @@ namespace sqlite_orm { */ template concept integral_fp_c = requires { - typename D::value_type; - D::value; - requires std::is_function_v>; - }; + typename D::value_type; + D::value; + requires std::is_function_v>; + }; /** * Constraints a deleter to be or to yield a function pointer. */ template concept yields_fp = requires(D d) { - // yielding function pointer by using the plus trick - {+d}; - requires std::is_function_v>; - }; + // yielding function pointer by using the plus trick + { +d }; + requires std::is_function_v>; + }; #endif #if __cpp_lib_concepts >= 201907L @@ -7516,7 +7587,7 @@ namespace sqlite_orm { template SQLITE_ORM_INLINE_VAR constexpr bool is_stateless_deleter_v = - std::is_empty::value&& std::is_default_constructible::value; + std::is_empty::value && std::is_default_constructible::value; template struct is_integral_fp_c : std::false_type {}; @@ -7577,7 +7648,8 @@ namespace sqlite_orm { * it doesn't check so explicitly, but a compiler error will occur. */ template - requires(!integral_fp_c) void xdestroy_proxy(void* p) noexcept { + requires(!integral_fp_c) + void xdestroy_proxy(void* p) noexcept { // C-casting `void* -> P*` like statement_binder> auto o = (P*)p; // ignoring return code @@ -7605,7 +7677,7 @@ namespace sqlite_orm { template SQLITE_ORM_INLINE_VAR constexpr bool can_yield_xdestroy_v = - can_yield_fp_v&& std::is_convertible, xdestroy_fn_t>::value; + can_yield_fp_v && std::is_convertible, xdestroy_fn_t>::value; template SQLITE_ORM_INLINE_VAR constexpr bool needs_xdestroy_proxy_v = @@ -7640,7 +7712,9 @@ namespace sqlite_orm { * Explicitly declared for better error messages. */ template - constexpr xdestroy_fn_t obtain_xdestroy_for(D, P*) noexcept requires(internal::is_unusable_for_xdestroy) { + constexpr xdestroy_fn_t obtain_xdestroy_for(D, P*) noexcept + requires(internal::is_unusable_for_xdestroy) + { static_assert(polyfill::always_false_v, "A function pointer, which is not of type xdestroy_fn_t, is prohibited."); return nullptr; @@ -7659,7 +7733,9 @@ namespace sqlite_orm { * is invocable with the non-q-qualified pointer value. */ template - constexpr xdestroy_fn_t obtain_xdestroy_for(D, P*) noexcept requires(internal::needs_xdestroy_proxy) { + constexpr xdestroy_fn_t obtain_xdestroy_for(D, P*) noexcept + requires(internal::needs_xdestroy_proxy) + { return internal::xdestroy_proxy; } @@ -7678,7 +7754,9 @@ namespace sqlite_orm { * is invocable with the non-q-qualified pointer value. */ template - constexpr xdestroy_fn_t obtain_xdestroy_for(D d, P*) noexcept requires(internal::yields_xdestroy) { + constexpr xdestroy_fn_t obtain_xdestroy_for(D d, P*) noexcept + requires(internal::yields_xdestroy) + { return d; } #else @@ -7701,6 +7779,7 @@ namespace sqlite_orm { #endif } + namespace sqlite_orm { /** @@ -7897,6 +7976,7 @@ namespace sqlite_orm { #endif // #include "../member_traits/member_traits.h" + namespace sqlite_orm { namespace internal { namespace polyfill { @@ -7975,6 +8055,7 @@ namespace sqlite_orm { // #include "pointer_value.h" + namespace sqlite_orm { /** @@ -8338,6 +8419,7 @@ namespace sqlite_orm { // #include "journal_mode.h" + #include // std::back_inserter #include // std::string #include // std::unique_ptr @@ -8414,6 +8496,7 @@ namespace sqlite_orm { // #include "is_std_ptr.h" + namespace sqlite_orm { /** @@ -8738,6 +8821,7 @@ namespace sqlite_orm { // #include "error_code.h" + namespace sqlite_orm { /** @@ -8933,6 +9017,7 @@ namespace sqlite_orm { // #include "indexed_column.h" + #include // std::string #include // std::move @@ -8940,6 +9025,7 @@ namespace sqlite_orm { // #include "ast/where.h" + namespace sqlite_orm { namespace internal { @@ -9003,6 +9089,7 @@ namespace sqlite_orm { } + namespace sqlite_orm { namespace internal { @@ -9056,6 +9143,7 @@ namespace sqlite_orm { // #include "alias.h" + namespace sqlite_orm { namespace internal { @@ -9171,6 +9259,7 @@ namespace sqlite_orm { // #include "storage_traits.h" + #include // std::tuple // #include "functional/cxx_type_traits_polyfill.h" @@ -9179,10 +9268,12 @@ namespace sqlite_orm { // #include "tuple_helper/tuple_transformer.h" + #include // std::tuple // #include "../functional/mpl.h" + namespace sqlite_orm { namespace internal { @@ -9208,6 +9299,7 @@ namespace sqlite_orm { // #include "storage_lookup.h" + #include // std::true_type, std::false_type, std::remove_const, std::enable_if #include #include // std::index_sequence @@ -9218,6 +9310,7 @@ namespace sqlite_orm { // #include "type_traits.h" + namespace sqlite_orm { namespace internal { @@ -9346,6 +9439,7 @@ namespace sqlite_orm { } } + namespace sqlite_orm { namespace internal { @@ -9376,6 +9470,7 @@ namespace sqlite_orm { // #include "function.h" + #include #include #include // std::string @@ -9388,6 +9483,7 @@ namespace sqlite_orm { // #include "functional/cxx_type_traits_polyfill.h" + namespace sqlite_orm { struct arg_values; @@ -9401,13 +9497,13 @@ namespace sqlite_orm { struct user_defined_function_base { using func_call = std::function< - void(sqlite3_context* context, void* functionPointer, int argsCount, sqlite3_value** values)>; - using final_call = std::function; + void(sqlite3_context *context, void *functionPointer, int argsCount, sqlite3_value **values)>; + using final_call = std::function; std::string name; int argumentsCount = 0; - std::function create; - void (*destroy)(int*) = nullptr; + std::function create; + void (*destroy)(int *) = nullptr; #ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED user_defined_function_base(decltype(name) name_, @@ -9539,7 +9635,7 @@ namespace sqlite_orm { constexpr bool is_same_pvt_v> = true; #if __cplusplus >= 201703L // using C++17 or higher - template + template SQLITE_ORM_CONSTEVAL bool assert_same_pointer_type() { constexpr bool valid = Binding == PointerArg; static_assert(valid, "Pointer value types of I-th argument do not match"); @@ -9622,6 +9718,7 @@ namespace sqlite_orm { } + namespace sqlite_orm { namespace internal { @@ -9908,6 +10005,7 @@ namespace sqlite_orm { // #include "functional/static_magic.h" + #include // std::false_type, std::true_type, std::integral_constant #include // std::forward @@ -9990,6 +10088,7 @@ namespace sqlite_orm { // #include "tuple_helper/tuple_iteration.h" + #include // std::tuple, std::get, std::tuple_element, std::tuple_size #include // std::index_sequence, std::make_index_sequence #include // std::forward, std::move @@ -10002,6 +10101,7 @@ namespace sqlite_orm { // #include "../functional/index_sequence_util.h" + namespace sqlite_orm { namespace internal { @@ -10131,6 +10231,7 @@ namespace sqlite_orm { // #include "column.h" + namespace sqlite_orm { namespace internal { @@ -10433,6 +10534,7 @@ namespace sqlite_orm { // #include "storage_lookup.h" + // interface functions namespace sqlite_orm { namespace internal { @@ -10517,6 +10619,7 @@ namespace sqlite_orm { // #include "storage_lookup.h" + namespace sqlite_orm { namespace internal { @@ -10553,6 +10656,7 @@ namespace sqlite_orm { #include // std::for_each, std::ranges::for_each // #include "functional/cxx_optional.h" + // #include "functional/cxx_universal.h" // #include "functional/cxx_functional_polyfill.h" @@ -10573,16 +10677,19 @@ namespace sqlite_orm { // #include "row_extractor_builder.h" + // #include "functional/cxx_universal.h" // #include "row_extractor.h" // #include "mapped_row_extractor.h" + #include // #include "object_from_column_builder.h" + #include #include // std::is_member_object_pointer @@ -10590,6 +10697,7 @@ namespace sqlite_orm { // #include "row_extractor.h" + namespace sqlite_orm { namespace internal { @@ -10630,6 +10738,7 @@ namespace sqlite_orm { } } + namespace sqlite_orm { namespace internal { @@ -10660,6 +10769,7 @@ namespace sqlite_orm { } + namespace sqlite_orm { namespace internal { @@ -10711,6 +10821,7 @@ namespace sqlite_orm { // #include "view.h" + #include #include // std::string #include // std::forward, std::move @@ -10722,6 +10833,7 @@ namespace sqlite_orm { // #include "iterator.h" + #include #include // std::shared_ptr, std::unique_ptr, std::make_shared #include // std::decay @@ -10742,6 +10854,7 @@ namespace sqlite_orm { // #include "util.h" + namespace sqlite_orm { namespace internal { @@ -10829,6 +10942,7 @@ namespace sqlite_orm { // #include "ast_iterator.h" + #include // std::vector #include // std::reference_wrapper @@ -10844,6 +10958,7 @@ namespace sqlite_orm { // #include "prepared_statement.h" + #include #include // std::unique_ptr #include // std::iterator_traits @@ -10861,12 +10976,14 @@ namespace sqlite_orm { // #include "connection_holder.h" + #include #include #include // std::string // #include "error_code.h" + namespace sqlite_orm { namespace internal { @@ -10939,6 +11056,7 @@ namespace sqlite_orm { // #include "values.h" + #include // std::vector #include // std::tuple #include // std::forward @@ -10947,6 +11065,7 @@ namespace sqlite_orm { // #include "functional/cxx_type_traits_polyfill.h" + namespace sqlite_orm { namespace internal { @@ -10985,12 +11104,14 @@ namespace sqlite_orm { // #include "ast/upsert_clause.h" + #include // std::tuple, std::make_tuple #include // std::false_type, std::true_type #include // std::forward, std::move // #include "../functional/cxx_type_traits_polyfill.h" + namespace sqlite_orm { namespace internal { #if SQLITE_VERSION_NUMBER >= 3024000 @@ -11046,6 +11167,7 @@ namespace sqlite_orm { #endif } + namespace sqlite_orm { namespace internal { @@ -11787,6 +11909,7 @@ namespace sqlite_orm { // #include "ast/excluded.h" + #include // std::move namespace sqlite_orm { @@ -11816,10 +11939,12 @@ namespace sqlite_orm { // #include "ast/exists.h" + #include // std::move // #include "../tags.h" + namespace sqlite_orm { namespace internal { @@ -11848,6 +11973,7 @@ namespace sqlite_orm { } } + namespace sqlite_orm { namespace internal { @@ -12527,6 +12653,7 @@ namespace sqlite_orm { // #include "util.h" + namespace sqlite_orm { namespace internal { @@ -12583,6 +12710,7 @@ namespace sqlite_orm { // #include "storage_base.h" + #include #include // std::function, std::bind #include // std::string @@ -12603,6 +12731,7 @@ namespace sqlite_orm { // #include "pragma.h" + #include #include // std::string #include // std::function @@ -12622,6 +12751,7 @@ namespace sqlite_orm { // #include "serializing_util.h" + #include // std::index_sequence #include #include @@ -12645,6 +12775,7 @@ namespace sqlite_orm { // #include "util.h" + namespace sqlite_orm { namespace internal { template @@ -12670,18 +12801,18 @@ namespace sqlite_orm { } } #else - inline void stream_sql_escaped(std::ostream& os, const std::string& str, char char2Escape) { - if(str.find(char2Escape) == str.npos) { - os << str; - } else { - for(char c: str) { - if(c == char2Escape) { - os << char2Escape; - } - os << c; + inline void stream_sql_escaped(std::ostream& os, const std::string& str, char char2Escape) { + if(str.find(char2Escape) == str.npos) { + os << str; + } else { + for(char c: str) { + if(c == char2Escape) { + os << char2Escape; } + os << c; } } + } #endif inline void stream_identifier(std::ostream& ss, @@ -13046,6 +13177,7 @@ namespace sqlite_orm { } } + namespace sqlite_orm { namespace internal { @@ -13254,6 +13386,7 @@ namespace sqlite_orm { // #include "limit_accessor.h" + #include #include // std::map #include // std::function @@ -13261,6 +13394,7 @@ namespace sqlite_orm { // #include "connection_holder.h" + namespace sqlite_orm { namespace internal { @@ -13394,11 +13528,13 @@ namespace sqlite_orm { // #include "transaction_guard.h" + #include // std::function #include // std::move // #include "connection_holder.h" + namespace sqlite_orm { namespace internal { @@ -13425,7 +13561,7 @@ namespace sqlite_orm { connection(std::move(connection_)), commit_func(move(commit_func_)), rollback_func(move(rollback_func_)) {} - transaction_guard_t(transaction_guard_t&& other) : + transaction_guard_t(transaction_guard_t &&other) : commit_on_destroy(other.commit_on_destroy), connection(std::move(other.connection)), commit_func(move(other.commit_func)), rollback_func(move(other.rollback_func)), gotta_fire(other.gotta_fire) { @@ -13442,7 +13578,7 @@ namespace sqlite_orm { } } - transaction_guard_t& operator=(transaction_guard_t&&) = delete; + transaction_guard_t &operator=(transaction_guard_t &&) = delete; /** * Call `COMMIT` explicitly. After this call @@ -13479,6 +13615,7 @@ namespace sqlite_orm { // #include "backup.h" + #include #include // std::system_error #include // std::string @@ -13489,6 +13626,7 @@ namespace sqlite_orm { // #include "connection_holder.h" + namespace sqlite_orm { namespace internal { @@ -13556,6 +13694,7 @@ namespace sqlite_orm { // #include "values_to_tuple.h" + #include #include // std::index_sequence, std::make_index_sequence #include // std::tuple, std::tuple_size, std::get @@ -13566,17 +13705,19 @@ namespace sqlite_orm { // #include "arg_values.h" + #include // #include "row_extractor.h" + namespace sqlite_orm { struct arg_value { arg_value() : arg_value(nullptr) {} - arg_value(sqlite3_value* value_) : value(value_) {} + arg_value(sqlite3_value *value_) : value(value_) {} template T get() const { @@ -13613,18 +13754,18 @@ namespace sqlite_orm { } private: - sqlite3_value* value = nullptr; + sqlite3_value *value = nullptr; }; struct arg_values { struct iterator { - iterator(const arg_values& container_, int index_) : + iterator(const arg_values &container_, int index_) : container(container_), index(index_), currentValue(index_ < int(container_.size()) ? container_[index_] : arg_value()) {} - iterator& operator++() { + iterator &operator++() { ++this->index; if(this->index < int(this->container.size())) { this->currentValue = this->container[this->index]; @@ -13653,27 +13794,27 @@ namespace sqlite_orm { } } - arg_value* operator->() const { + arg_value *operator->() const { return &this->currentValue; } - bool operator==(const iterator& other) const { + bool operator==(const iterator &other) const { return &other.container == &this->container && other.index == this->index; } - bool operator!=(const iterator& other) const { + bool operator!=(const iterator &other) const { return !(*this == other); } private: - const arg_values& container; + const arg_values &container; int index = 0; mutable arg_value currentValue; }; arg_values() : arg_values(0, nullptr) {} - arg_values(int argsCount_, sqlite3_value** values_) : argsCount(argsCount_), values(values_) {} + arg_values(int argsCount_, sqlite3_value **values_) : argsCount(argsCount_), values(values_) {} size_t size() const { return this->argsCount; @@ -13685,7 +13826,7 @@ namespace sqlite_orm { arg_value operator[](int index) const { if(index < this->argsCount && index >= 0) { - sqlite3_value* value = this->values[index]; + sqlite3_value *value = this->values[index]; return {value}; } else { throw std::system_error{orm_error_code::index_is_out_of_bounds}; @@ -13706,10 +13847,11 @@ namespace sqlite_orm { private: int argsCount = 0; - sqlite3_value** values = nullptr; + sqlite3_value **values = nullptr; }; } + namespace sqlite_orm { namespace internal { @@ -13731,13 +13873,13 @@ namespace sqlite_orm { (this->extract(values[Idx], std::get(tuple)), ...); } #else - template - void operator()(sqlite3_value** values, Tpl& tuple, std::index_sequence) const { - this->extract(values[I], std::get(tuple)); - (*this)(values, tuple, std::index_sequence{}); - } - template - void operator()(sqlite3_value** /*values*/, Tpl&, std::index_sequence) const {} + template + void operator()(sqlite3_value** values, Tpl& tuple, std::index_sequence) const { + this->extract(values[I], std::get(tuple)); + (*this)(values, tuple, std::index_sequence{}); + } + template + void operator()(sqlite3_value** /*values*/, Tpl&, std::index_sequence) const {} #endif template void extract(sqlite3_value* value, T& t) const { @@ -13753,6 +13895,7 @@ namespace sqlite_orm { // #include "serializing_util.h" + namespace sqlite_orm { namespace internal { @@ -14519,11 +14662,13 @@ namespace sqlite_orm { // #include "expression_object_type.h" + #include // std::decay #include // std::reference_wrapper // #include "prepared_statement.h" + namespace sqlite_orm { namespace internal { @@ -14657,6 +14802,7 @@ namespace sqlite_orm { // #include "statement_serializer.h" + #include // std::stringstream #include // std::string #include // std::enable_if, std::remove_pointer @@ -14669,6 +14815,7 @@ namespace sqlite_orm { #include // #include "functional/cxx_string_view.h" + // #include "functional/cxx_universal.h" // #include "functional/cxx_functional_polyfill.h" @@ -14711,6 +14858,7 @@ namespace sqlite_orm { // #include "table_name_collector.h" + #include // std::set #include // std::string #include // std::function @@ -14726,13 +14874,14 @@ namespace sqlite_orm { // #include "core_functions.h" + namespace sqlite_orm { namespace internal { struct table_name_collector { using table_name_set = std::set>; - using find_table_name_t = std::function; + using find_table_name_t = std::function; find_table_name_t find_table_name; mutable table_name_set table_names; @@ -14742,7 +14891,7 @@ namespace sqlite_orm { table_name_collector(find_table_name_t find_table_name) : find_table_name{move(find_table_name)} {} template - table_name_set operator()(const T&) const { + table_name_set operator()(const T &) const { return {}; } @@ -14752,17 +14901,17 @@ namespace sqlite_orm { } template - void operator()(const column_pointer&) const { + void operator()(const column_pointer &) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } template - void operator()(const alias_column_t& a) const { + void operator()(const alias_column_t &a) const { (*this)(a.column, alias_extractor::get()); } template - void operator()(const count_asterisk_t&) const { + void operator()(const count_asterisk_t &) const { auto tableName = this->find_table_name(typeid(T)); if(!tableName.empty()) { table_names.emplace(move(tableName), ""); @@ -14770,12 +14919,12 @@ namespace sqlite_orm { } template = true> - void operator()(const asterisk_t&) const { + void operator()(const asterisk_t &) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } template = true> - void operator()(const asterisk_t&) const { + void operator()(const asterisk_t &) const { // note: not all alias classes have a nested A::type static_assert(polyfill::is_detected_v, "alias must have a nested alias::type typename"); @@ -14784,22 +14933,22 @@ namespace sqlite_orm { } template - void operator()(const object_t&) const { + void operator()(const object_t &) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } template - void operator()(const table_rowid_t&) const { + void operator()(const table_rowid_t &) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } template - void operator()(const table_oid_t&) const { + void operator()(const table_oid_t &) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } template - void operator()(const table__rowid_t&) const { + void operator()(const table__rowid_t &) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } }; @@ -14810,6 +14959,7 @@ namespace sqlite_orm { // #include "column_names_getter.h" + #include // std::system_error #include // std::string #include // std::vector @@ -14825,6 +14975,7 @@ namespace sqlite_orm { // #include "util.h" + namespace sqlite_orm { namespace internal { @@ -14929,6 +15080,7 @@ namespace sqlite_orm { // #include "order_by_serializer.h" + #include // std::string #include // std::stringstream @@ -15020,6 +15172,7 @@ namespace sqlite_orm { // #include "util.h" + namespace sqlite_orm { namespace internal { @@ -15765,7 +15918,7 @@ namespace sqlite_orm { using statement_type = conflict_clause_t; template - std::string operator()(const statement_type& statement, const Ctx& context) const { + std::string operator()(const statement_type& statement, const Ctx&) const { switch(statement) { case conflict_clause_t::rollback: return "ROLLBACK"; @@ -17050,6 +17203,7 @@ namespace sqlite_orm { // #include "serializing_util.h" + namespace sqlite_orm { namespace internal { @@ -17582,7 +17736,7 @@ namespace sqlite_orm { static_assert(is_preparable_v, "Expression must be a high-level statement"); decltype(auto) e2 = static_if>( - [](auto expression) -> auto { + [](auto expression) -> auto{ expression.highest_level = true; return expression; }, @@ -17851,7 +18005,7 @@ namespace sqlite_orm { #if SQLITE_VERSION_NUMBER >= 3035000 // DROP COLUMN feature exists (v3.35.0) res = sync_schema_result::old_columns_removed; #else - gottaCreateTable = true; + gottaCreateTable = true; #endif } else { res = sync_schema_result::old_columns_removed; @@ -18170,13 +18324,13 @@ namespace sqlite_orm { std::ref(processObject), std::ref(expression.transformer)); #else - auto& transformer = expression.transformer; - std::for_each(expression.range.first, - expression.range.second, - [&processObject, &transformer](auto& item) { - const object_type& object = polyfill::invoke(transformer, item); - processObject(object); - }); + auto& transformer = expression.transformer; + std::for_each(expression.range.first, + expression.range.second, + [&processObject, &transformer](auto& item) { + const object_type& object = polyfill::invoke(transformer, item); + processObject(object); + }); #endif }, [&processObject](auto& expression) { @@ -18216,13 +18370,13 @@ namespace sqlite_orm { std::ref(processObject), std::ref(expression.transformer)); #else - auto& transformer = expression.transformer; - std::for_each(expression.range.first, - expression.range.second, - [&processObject, &transformer](auto& item) { - const object_type& object = polyfill::invoke(transformer, item); - processObject(object); - }); + auto& transformer = expression.transformer; + std::for_each(expression.range.first, + expression.range.second, + [&processObject, &transformer](auto& item) { + const object_type& object = polyfill::invoke(transformer, item); + processObject(object); + }); #endif }, [&processObject](auto& expression) { @@ -18314,22 +18468,22 @@ namespace sqlite_orm { } return move(res).value(); #else - auto& table = this->get_table(); - auto stepRes = sqlite3_step(stmt); - switch(stepRes) { - case SQLITE_ROW: { - T res; - object_from_column_builder builder{res, stmt}; - table.for_each_column(builder); - return res; - } break; - case SQLITE_DONE: { - throw std::system_error{orm_error_code::not_found}; - } break; - default: { - throw_translated_sqlite_error(stmt); - } + auto& table = this->get_table(); + auto stepRes = sqlite3_step(stmt); + switch(stepRes) { + case SQLITE_ROW: { + T res; + object_from_column_builder builder{res, stmt}; + table.for_each_column(builder); + return res; + } break; + case SQLITE_DONE: { + throw std::system_error{orm_error_code::not_found}; + } break; + default: { + throw_translated_sqlite_error(stmt); } + } #endif } @@ -18440,6 +18594,7 @@ namespace sqlite_orm { #include // std::reference_wrapper // #include "functional/cxx_optional.h" + // #include "tuple_helper/tuple_filter.h" // #include "conditions.h" @@ -18466,6 +18621,7 @@ namespace sqlite_orm { // #include "ast/group_by.h" + namespace sqlite_orm { namespace internal { @@ -18770,6 +18926,7 @@ namespace sqlite_orm { // #include "expression_object_type.h" + namespace sqlite_orm { template @@ -18949,6 +19106,7 @@ namespace sqlite_orm { // #include "pointer_value.h" + namespace sqlite_orm { inline constexpr const char carray_pvt_name[] = "carray"; @@ -19021,6 +19179,7 @@ namespace sqlite_orm { // #include "table.h" + namespace sqlite_orm { #ifdef SQLITE_ENABLE_DBSTAT_VTAB struct dbstat { @@ -19063,6 +19222,7 @@ namespace sqlite_orm { * this file is also used to provide definitions of interface methods 'hitting the database'. */ + #include // std::make_unique // #include "../functional/cxx_core_features.h" @@ -19079,6 +19239,7 @@ namespace sqlite_orm { // #include "../column.h" + namespace sqlite_orm { namespace internal { @@ -19118,6 +19279,7 @@ namespace sqlite_orm { // #include "../table.h" + namespace sqlite_orm { namespace internal { @@ -19145,9 +19307,9 @@ namespace sqlite_orm { #if __cpp_lib_ranges >= 201911L auto it = std::ranges::find(res, columnName, &table_xinfo::name); #else - auto it = std::find_if(res.begin(), res.end(), [&columnName](const table_xinfo& ti) { - return ti.name == columnName; - }); + auto it = std::find_if(res.begin(), res.end(), [&columnName](const table_xinfo& ti) { + return ti.name == columnName; + }); #endif if(it != res.end()) { it->pk = static_cast(i + 1); @@ -19178,6 +19340,7 @@ namespace sqlite_orm { // #include "../storage.h" + namespace sqlite_orm { namespace internal { @@ -19220,9 +19383,9 @@ namespace sqlite_orm { } res = sync_schema_result::old_columns_removed; #else - // extra table columns than storage columns - this->backup_table(db, table, {}); - res = sync_schema_result::old_columns_removed; + // extra table columns than storage columns + this->backup_table(db, table, {}); + res = sync_schema_result::old_columns_removed; #endif } @@ -19286,11 +19449,11 @@ namespace sqlite_orm { #if __cpp_lib_ranges >= 201911L auto columnToIgnoreIt = std::ranges::find(columnsToIgnore, columnName, &table_xinfo::name); #else - auto columnToIgnoreIt = std::find_if(columnsToIgnore.begin(), - columnsToIgnore.end(), - [&columnName](const table_xinfo* tableInfo) { - return columnName == tableInfo->name; - }); + auto columnToIgnoreIt = std::find_if(columnsToIgnore.begin(), + columnsToIgnore.end(), + [&columnName](const table_xinfo* tableInfo) { + return columnName == tableInfo->name; + }); #endif if(columnToIgnoreIt == columnsToIgnore.end()) { columnNames.push_back(cref(columnName)); From b9bcc2948bf6849e15bd353e0e191f8b9486fe82 Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Mon, 16 Jan 2023 10:02:37 +0200 Subject: [PATCH 08/22] Fixed availability of pointer passing example --- examples/chrono_binding.cpp | 12 ++++++------ examples/pointer_passing_interface.cpp | 10 ++++++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/examples/chrono_binding.cpp b/examples/chrono_binding.cpp index 81538ae45..5400f48d5 100644 --- a/examples/chrono_binding.cpp +++ b/examples/chrono_binding.cpp @@ -1,15 +1,14 @@ #include -#include -#include -#include -#include -#include - #if __cpp_lib_chrono >= 201907L && __cpp_lib_format >= 201907L #define ENABLE_THIS_EXAMPLE #endif #ifdef ENABLE_THIS_EXAMPLE +#include +#include +#include +#include +#include /////////////////////////////// /// sys_days binding as TEXT @@ -168,4 +167,5 @@ int main(int, char**) { year_month_day ymd = pers.birthdate; // using the implicit operator from sys_days to year_month_day assert(ymd == birthdate); #endif + return 0; } diff --git a/examples/pointer_passing_interface.cpp b/examples/pointer_passing_interface.cpp index 65d833707..f9c68627d 100644 --- a/examples/pointer_passing_interface.cpp +++ b/examples/pointer_passing_interface.cpp @@ -16,7 +16,12 @@ * * Note: pointers are only accessible within application code, and therefore unleakable. */ +#include #ifdef SQLITE_ORM_INLINE_VARIABLES_SUPPORTED +#define ENABLE_THIS_EXAMPLE +#endif + +#ifdef ENABLE_THIS_EXAMPLE #include #include #include @@ -24,7 +29,6 @@ #include #include #include -#include using namespace sqlite_orm; @@ -72,8 +76,10 @@ struct str_alias : alias_tag { return str; } }; +#endif int main() { +#ifdef ENABLE_THIS_EXAMPLE // table structure for results of some type struct Result { int id = 0; @@ -217,6 +223,6 @@ int main() { cout << endl; } +#endif return 0; } -#endif From 3f1a03b074bf1ffe6b32a7e1c6758731de644993 Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Mon, 16 Jan 2023 10:10:36 +0200 Subject: [PATCH 09/22] Disable vcpkg telemetry on appveyor builds --- appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 13a520740..0d1619e28 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -97,7 +97,7 @@ for: install: - |- git clone --depth 1 --branch 2023.01.09 https://github.com/microsoft/vcpkg.git "$HOME/vcpkg" - C:\Tools\vcpkg\bootstrap-vcpkg.bat + C:\Tools\vcpkg\bootstrap-vcpkg.bat -disableMetrics C:\Tools\vcpkg\vcpkg integrate install vcpkg install sqlite3:%platform%-windows before_build: @@ -124,7 +124,7 @@ for: install: - |- git clone --depth 1 --branch 2023.01.09 https://github.com/microsoft/vcpkg.git $HOME/vcpkg - $HOME/vcpkg/bootstrap-vcpkg.sh + $HOME/vcpkg/bootstrap-vcpkg.sh -disableMetrics $HOME/vcpkg/vcpkg integrate install --overlay-triplets=vcpkg/triplets vcpkg install sqlite3 --overlay-triplets=vcpkg/triplets before_build: @@ -150,7 +150,7 @@ for: install: - |- git clone --depth 1 --branch 2023.01.09 https://github.com/microsoft/vcpkg.git $HOME/vcpkg - $HOME/vcpkg/bootstrap-vcpkg.sh + $HOME/vcpkg/bootstrap-vcpkg.sh -disableMetrics $HOME/vcpkg/vcpkg integrate install --overlay-triplets=vcpkg/triplets vcpkg install sqlite3 --overlay-triplets=vcpkg/triplets before_build: From 0a20570cbef3a695cd7d546a192ddce044a79c86 Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Mon, 16 Jan 2023 10:37:59 +0200 Subject: [PATCH 10/22] Correctly pin appveyor vcpkg test environment --- appveyor.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 0d1619e28..0b8eea9cc 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -96,7 +96,9 @@ for: if "%appveyor_build_worker_image%"=="Visual Studio 2015" (set generator="Visual Studio 14 2015" %architecture%) install: - |- - git clone --depth 1 --branch 2023.01.09 https://github.com/microsoft/vcpkg.git "$HOME/vcpkg" + pushd C:\Tools\vcpkg + git fetch --tags && git checkout 2023.01.09 + popd C:\Tools\vcpkg\bootstrap-vcpkg.bat -disableMetrics C:\Tools\vcpkg\vcpkg integrate install vcpkg install sqlite3:%platform%-windows @@ -123,7 +125,9 @@ for: # using custom vcpkg triplets for building and linking dynamic dependent libraries install: - |- - git clone --depth 1 --branch 2023.01.09 https://github.com/microsoft/vcpkg.git $HOME/vcpkg + pushd $HOME/vcpkg + git fetch --tags && git checkout 2023.01.09 + popd $HOME/vcpkg/bootstrap-vcpkg.sh -disableMetrics $HOME/vcpkg/vcpkg integrate install --overlay-triplets=vcpkg/triplets vcpkg install sqlite3 --overlay-triplets=vcpkg/triplets From 9532b82cc3084b73b340d899b801c24aad6764b5 Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Mon, 16 Jan 2023 11:07:28 +0200 Subject: [PATCH 11/22] Clang-formatted all files --- include/sqlite_orm/sqlite_orm.h | 318 +++++++++---------------------- tests/storage_non_crud_tests.cpp | 3 +- 2 files changed, 91 insertions(+), 230 deletions(-) diff --git a/include/sqlite_orm/sqlite_orm.h b/include/sqlite_orm/sqlite_orm.h index 56022ee29..dfb758807 100644 --- a/include/sqlite_orm/sqlite_orm.h +++ b/include/sqlite_orm/sqlite_orm.h @@ -16,7 +16,6 @@ __pragma(push_macro("max")) // #include "cxx_universal.h" - /* * This header makes central C++ functionality on which sqlite_orm depends universally available: * - alternative operator representations @@ -35,7 +34,6 @@ using std::nullptr_t; // #include "cxx_core_features.h" - #ifdef __has_cpp_attribute #define SQLITE_ORM_HAS_CPP_ATTRIBUTE(attr) __has_cpp_attribute(attr) #else @@ -109,7 +107,6 @@ using std::nullptr_t; // #include "cxx_compiler_quirks.h" - #ifdef __clang__ #define SQLITE_ORM_DO_PRAGMA(...) _Pragma(#__VA_ARGS__) #endif @@ -139,8 +136,6 @@ using std::nullptr_t; #define SQLITE_ORM_BROKEN_VARIADIC_PACK_EXPANSION #endif - - namespace sqlite_orm { namespace internal { namespace polyfill { @@ -282,7 +277,6 @@ namespace sqlite_orm { namespace polyfill = internal::polyfill; } - namespace sqlite_orm { // C++ generic traits used throughout the library namespace internal { @@ -511,10 +505,8 @@ namespace sqlite_orm { #include // std::vector // #include "functional/cxx_optional.h" - // #include "cxx_core_features.h" - #if SQLITE_ORM_HAS_INCLUDE() #include #endif @@ -523,7 +515,6 @@ namespace sqlite_orm { #define SQLITE_ORM_OPTIONAL_SUPPORTED #endif - // #include "functional/cxx_type_traits_polyfill.h" // #include "type_traits.h" @@ -560,7 +551,6 @@ namespace sqlite_orm { }; } - namespace sqlite_orm { /** @@ -659,7 +649,6 @@ namespace sqlite_orm { // #include "functional/mpl.h" - /* * Symbols for 'template metaprogramming' (compile-time template programming), * inspired by the MPL of Aleksey Gurtovoy and David Abrahams. @@ -688,7 +677,6 @@ namespace sqlite_orm { // #include "cxx_type_traits_polyfill.h" - namespace sqlite_orm { namespace internal { namespace mpl { @@ -969,7 +957,6 @@ namespace sqlite_orm { // #include "tuple_helper/same_or_void.h" - namespace sqlite_orm { namespace internal { @@ -999,7 +986,6 @@ namespace sqlite_orm { // #include "tuple_helper/tuple_traits.h" - #include // std::is_same #include @@ -1007,7 +993,6 @@ namespace sqlite_orm { // #include "../functional/mpl.h" - namespace sqlite_orm { namespace internal { /* @@ -1055,7 +1040,6 @@ namespace sqlite_orm { } // #include "tuple_helper/tuple_filter.h" - #include // std::integral_constant, std::index_sequence, std::conditional, std::declval #include // std::tuple @@ -1063,7 +1047,6 @@ namespace sqlite_orm { // #include "../functional/index_sequence_util.h" - #include // std::index_sequence, std::make_index_sequence // #include "../functional/cxx_universal.h" @@ -1132,7 +1115,6 @@ namespace sqlite_orm { } } - namespace sqlite_orm { namespace internal { @@ -1224,7 +1206,6 @@ namespace sqlite_orm { // #include "table_type_of.h" - namespace sqlite_orm { namespace internal { @@ -1261,7 +1242,6 @@ namespace sqlite_orm { // #include "type_printer.h" - namespace sqlite_orm { namespace internal { @@ -1808,10 +1788,8 @@ namespace sqlite_orm { #include // std::shared_ptr, std::unique_ptr // #include "functional/cxx_optional.h" - // #include "functional/cxx_type_traits_polyfill.h" - namespace sqlite_orm { /** @@ -1851,10 +1829,8 @@ namespace sqlite_orm { #include // std::move // #include "functional/cxx_optional.h" - // #include "tags.h" - namespace sqlite_orm { namespace internal { struct negatable_t {}; @@ -1868,13 +1844,10 @@ namespace sqlite_orm { // #include "serialize_result_type.h" - // #include "functional/cxx_string_view.h" - // #include "cxx_core_features.h" - #if SQLITE_ORM_HAS_INCLUDE() #include #endif @@ -1897,7 +1870,6 @@ namespace sqlite_orm { } } - namespace sqlite_orm { namespace internal { @@ -2186,14 +2158,12 @@ namespace sqlite_orm { // #include "member_traits/member_traits.h" - #include // std::enable_if, std::is_function, std::true_type, std::false_type // #include "../functional/cxx_universal.h" // #include "../functional/cxx_type_traits_polyfill.h" - namespace sqlite_orm { namespace internal { // SFINAE friendly trait to get a member object pointer's field type @@ -2285,7 +2255,6 @@ namespace sqlite_orm { // #include "constraints.h" - namespace sqlite_orm { namespace internal { @@ -2464,14 +2433,12 @@ namespace sqlite_orm { #endif // SQLITE_ORM_OMITS_CODECVT // #include "functional/cxx_optional.h" - // #include "functional/cxx_universal.h" // #include "functional/cxx_type_traits_polyfill.h" // #include "is_std_ptr.h" - namespace sqlite_orm { /** @@ -2635,7 +2602,6 @@ namespace sqlite_orm { // #include "optional_container.h" - namespace sqlite_orm { namespace internal { @@ -2670,7 +2636,6 @@ namespace sqlite_orm { // #include "serializer_context.h" - namespace sqlite_orm { namespace internal { @@ -2712,17 +2677,14 @@ namespace sqlite_orm { // #include "expression.h" - #include #include // std::move, std::forward // #include "functional/cxx_optional.h" - // #include "functional/cxx_universal.h" // #include "operators.h" - namespace sqlite_orm { namespace internal { @@ -2801,7 +2763,6 @@ namespace sqlite_orm { // #include "literal.h" - namespace sqlite_orm { namespace internal { @@ -2818,7 +2779,6 @@ namespace sqlite_orm { } } - namespace sqlite_orm { namespace internal { @@ -4236,7 +4196,6 @@ namespace sqlite_orm { // #include "conditions.h" - namespace sqlite_orm { namespace internal { @@ -4350,7 +4309,6 @@ namespace sqlite_orm { // #include "is_base_of_template.h" - #include // std::true_type, std::false_type, std::declval namespace sqlite_orm { @@ -4396,10 +4354,8 @@ namespace sqlite_orm { // #include "ast/into.h" - // #include "../functional/cxx_type_traits_polyfill.h" - namespace sqlite_orm { namespace internal { @@ -4418,7 +4374,6 @@ namespace sqlite_orm { } } - namespace sqlite_orm { using int64 = sqlite_int64; @@ -6522,7 +6477,6 @@ namespace sqlite_orm { #include // std::tuple, std::get, std::tuple_size // #include "functional/cxx_optional.h" - // #include "functional/cxx_universal.h" // #include "functional/cxx_type_traits_polyfill.h" @@ -6535,7 +6489,6 @@ namespace sqlite_orm { // #include "ast/where.h" - #include // std::false_type, std::true_type #include // std::move @@ -6545,7 +6498,6 @@ namespace sqlite_orm { // #include "../serialize_result_type.h" - namespace sqlite_orm { namespace internal { @@ -6593,14 +6545,12 @@ namespace sqlite_orm { // #include "ast/group_by.h" - #include // std::tuple, std::make_tuple #include // std::true_type, std::false_type #include // std::forward, std::move // #include "../functional/cxx_type_traits_polyfill.h" - namespace sqlite_orm { namespace internal { @@ -6670,7 +6620,6 @@ namespace sqlite_orm { // #include "core_functions.h" - namespace sqlite_orm { namespace internal { @@ -7147,7 +7096,6 @@ namespace sqlite_orm { // #include "functional/cxx_universal.h" - namespace sqlite_orm { struct table_info { @@ -7204,7 +7152,6 @@ namespace sqlite_orm { // #include "optional_container.h" - // NOTE Idea : Maybe also implement a custom trigger system to call a c++ callback when a trigger triggers ? // (Could be implemented with a normal trigger that insert or update an internal table and then retreive // the event in the C++ code, to call the C++ user callback, with update hooks: https://www.sqlite.org/c3ref/update_hook.html) @@ -7237,7 +7184,7 @@ namespace sqlite_orm { partial_trigger_t(T trigger_base, S... statements) : base{std::move(trigger_base)}, statements{std::make_tuple(std::forward(statements)...)} {} - partial_trigger_t &end() { + partial_trigger_t& end() { return *this; } }; @@ -7306,7 +7253,7 @@ namespace sqlite_orm { trigger_base_t(trigger_type_base type_base_) : type_base(std::move(type_base_)) {} - trigger_base_t &for_each_row() { + trigger_base_t& for_each_row() { this->do_for_each_row = true; return *this; } @@ -7467,7 +7414,7 @@ namespace sqlite_orm { } template - internal::trigger_t make_trigger(std::string name, const internal::partial_trigger_t &part) { + internal::trigger_t make_trigger(std::string name, const internal::partial_trigger_t& part) { SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(return {move(name), std::move(part.base), std::move(part.statements)}); } @@ -7527,7 +7474,6 @@ namespace sqlite_orm { // #include "xdestroy_handling.h" - #include // std::integral_constant #if defined(SQLITE_ORM_CONCEPTS_SUPPORTED) && SQLITE_ORM_HAS_INCLUDE() #include @@ -7537,7 +7483,6 @@ namespace sqlite_orm { // #include "functional/cxx_type_traits_polyfill.h" - namespace sqlite_orm { using xdestroy_fn_t = void (*)(void*); @@ -7779,7 +7724,6 @@ namespace sqlite_orm { #endif } - namespace sqlite_orm { /** @@ -7976,7 +7920,6 @@ namespace sqlite_orm { #endif // #include "../member_traits/member_traits.h" - namespace sqlite_orm { namespace internal { namespace polyfill { @@ -8055,7 +7998,6 @@ namespace sqlite_orm { // #include "pointer_value.h" - namespace sqlite_orm { /** @@ -8419,7 +8361,6 @@ namespace sqlite_orm { // #include "journal_mode.h" - #include // std::back_inserter #include // std::string #include // std::unique_ptr @@ -8496,7 +8437,6 @@ namespace sqlite_orm { // #include "is_std_ptr.h" - namespace sqlite_orm { /** @@ -8821,7 +8761,6 @@ namespace sqlite_orm { // #include "error_code.h" - namespace sqlite_orm { /** @@ -9017,7 +8956,6 @@ namespace sqlite_orm { // #include "indexed_column.h" - #include // std::string #include // std::move @@ -9025,7 +8963,6 @@ namespace sqlite_orm { // #include "ast/where.h" - namespace sqlite_orm { namespace internal { @@ -9089,7 +9026,6 @@ namespace sqlite_orm { } - namespace sqlite_orm { namespace internal { @@ -9143,7 +9079,6 @@ namespace sqlite_orm { // #include "alias.h" - namespace sqlite_orm { namespace internal { @@ -9259,7 +9194,6 @@ namespace sqlite_orm { // #include "storage_traits.h" - #include // std::tuple // #include "functional/cxx_type_traits_polyfill.h" @@ -9268,12 +9202,10 @@ namespace sqlite_orm { // #include "tuple_helper/tuple_transformer.h" - #include // std::tuple // #include "../functional/mpl.h" - namespace sqlite_orm { namespace internal { @@ -9299,7 +9231,6 @@ namespace sqlite_orm { // #include "storage_lookup.h" - #include // std::true_type, std::false_type, std::remove_const, std::enable_if #include #include // std::index_sequence @@ -9310,7 +9241,6 @@ namespace sqlite_orm { // #include "type_traits.h" - namespace sqlite_orm { namespace internal { @@ -9439,7 +9369,6 @@ namespace sqlite_orm { } } - namespace sqlite_orm { namespace internal { @@ -9470,7 +9399,6 @@ namespace sqlite_orm { // #include "function.h" - #include #include #include // std::string @@ -9483,7 +9411,6 @@ namespace sqlite_orm { // #include "functional/cxx_type_traits_polyfill.h" - namespace sqlite_orm { struct arg_values; @@ -9497,13 +9424,13 @@ namespace sqlite_orm { struct user_defined_function_base { using func_call = std::function< - void(sqlite3_context *context, void *functionPointer, int argsCount, sqlite3_value **values)>; - using final_call = std::function; + void(sqlite3_context* context, void* functionPointer, int argsCount, sqlite3_value** values)>; + using final_call = std::function; std::string name; int argumentsCount = 0; - std::function create; - void (*destroy)(int *) = nullptr; + std::function create; + void (*destroy)(int*) = nullptr; #ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED user_defined_function_base(decltype(name) name_, @@ -9635,7 +9562,7 @@ namespace sqlite_orm { constexpr bool is_same_pvt_v> = true; #if __cplusplus >= 201703L // using C++17 or higher - template + template SQLITE_ORM_CONSTEVAL bool assert_same_pointer_type() { constexpr bool valid = Binding == PointerArg; static_assert(valid, "Pointer value types of I-th argument do not match"); @@ -9718,7 +9645,6 @@ namespace sqlite_orm { } - namespace sqlite_orm { namespace internal { @@ -10005,7 +9931,6 @@ namespace sqlite_orm { // #include "functional/static_magic.h" - #include // std::false_type, std::true_type, std::integral_constant #include // std::forward @@ -10088,7 +10013,6 @@ namespace sqlite_orm { // #include "tuple_helper/tuple_iteration.h" - #include // std::tuple, std::get, std::tuple_element, std::tuple_size #include // std::index_sequence, std::make_index_sequence #include // std::forward, std::move @@ -10101,7 +10025,6 @@ namespace sqlite_orm { // #include "../functional/index_sequence_util.h" - namespace sqlite_orm { namespace internal { @@ -10231,7 +10154,6 @@ namespace sqlite_orm { // #include "column.h" - namespace sqlite_orm { namespace internal { @@ -10534,7 +10456,6 @@ namespace sqlite_orm { // #include "storage_lookup.h" - // interface functions namespace sqlite_orm { namespace internal { @@ -10619,7 +10540,6 @@ namespace sqlite_orm { // #include "storage_lookup.h" - namespace sqlite_orm { namespace internal { @@ -10656,7 +10576,6 @@ namespace sqlite_orm { #include // std::for_each, std::ranges::for_each // #include "functional/cxx_optional.h" - // #include "functional/cxx_universal.h" // #include "functional/cxx_functional_polyfill.h" @@ -10677,19 +10596,16 @@ namespace sqlite_orm { // #include "row_extractor_builder.h" - // #include "functional/cxx_universal.h" // #include "row_extractor.h" // #include "mapped_row_extractor.h" - #include // #include "object_from_column_builder.h" - #include #include // std::is_member_object_pointer @@ -10697,7 +10613,6 @@ namespace sqlite_orm { // #include "row_extractor.h" - namespace sqlite_orm { namespace internal { @@ -10738,7 +10653,6 @@ namespace sqlite_orm { } } - namespace sqlite_orm { namespace internal { @@ -10769,7 +10683,6 @@ namespace sqlite_orm { } - namespace sqlite_orm { namespace internal { @@ -10821,7 +10734,6 @@ namespace sqlite_orm { // #include "view.h" - #include #include // std::string #include // std::forward, std::move @@ -10833,7 +10745,6 @@ namespace sqlite_orm { // #include "iterator.h" - #include #include // std::shared_ptr, std::unique_ptr, std::make_shared #include // std::decay @@ -10854,7 +10765,6 @@ namespace sqlite_orm { // #include "util.h" - namespace sqlite_orm { namespace internal { @@ -10942,7 +10852,6 @@ namespace sqlite_orm { // #include "ast_iterator.h" - #include // std::vector #include // std::reference_wrapper @@ -10958,7 +10867,6 @@ namespace sqlite_orm { // #include "prepared_statement.h" - #include #include // std::unique_ptr #include // std::iterator_traits @@ -10976,14 +10884,12 @@ namespace sqlite_orm { // #include "connection_holder.h" - #include #include #include // std::string // #include "error_code.h" - namespace sqlite_orm { namespace internal { @@ -11056,7 +10962,6 @@ namespace sqlite_orm { // #include "values.h" - #include // std::vector #include // std::tuple #include // std::forward @@ -11065,7 +10970,6 @@ namespace sqlite_orm { // #include "functional/cxx_type_traits_polyfill.h" - namespace sqlite_orm { namespace internal { @@ -11104,14 +11008,12 @@ namespace sqlite_orm { // #include "ast/upsert_clause.h" - #include // std::tuple, std::make_tuple #include // std::false_type, std::true_type #include // std::forward, std::move // #include "../functional/cxx_type_traits_polyfill.h" - namespace sqlite_orm { namespace internal { #if SQLITE_VERSION_NUMBER >= 3024000 @@ -11167,7 +11069,6 @@ namespace sqlite_orm { #endif } - namespace sqlite_orm { namespace internal { @@ -11909,7 +11810,6 @@ namespace sqlite_orm { // #include "ast/excluded.h" - #include // std::move namespace sqlite_orm { @@ -11939,12 +11839,10 @@ namespace sqlite_orm { // #include "ast/exists.h" - #include // std::move // #include "../tags.h" - namespace sqlite_orm { namespace internal { @@ -11973,7 +11871,6 @@ namespace sqlite_orm { } } - namespace sqlite_orm { namespace internal { @@ -12653,7 +12550,6 @@ namespace sqlite_orm { // #include "util.h" - namespace sqlite_orm { namespace internal { @@ -12710,7 +12606,6 @@ namespace sqlite_orm { // #include "storage_base.h" - #include #include // std::function, std::bind #include // std::string @@ -12731,7 +12626,6 @@ namespace sqlite_orm { // #include "pragma.h" - #include #include // std::string #include // std::function @@ -12751,7 +12645,6 @@ namespace sqlite_orm { // #include "serializing_util.h" - #include // std::index_sequence #include #include @@ -12775,7 +12668,6 @@ namespace sqlite_orm { // #include "util.h" - namespace sqlite_orm { namespace internal { template @@ -12801,18 +12693,18 @@ namespace sqlite_orm { } } #else - inline void stream_sql_escaped(std::ostream& os, const std::string& str, char char2Escape) { - if(str.find(char2Escape) == str.npos) { - os << str; - } else { - for(char c: str) { - if(c == char2Escape) { - os << char2Escape; + inline void stream_sql_escaped(std::ostream& os, const std::string& str, char char2Escape) { + if(str.find(char2Escape) == str.npos) { + os << str; + } else { + for(char c: str) { + if(c == char2Escape) { + os << char2Escape; + } + os << c; } - os << c; } } - } #endif inline void stream_identifier(std::ostream& ss, @@ -13177,7 +13069,6 @@ namespace sqlite_orm { } } - namespace sqlite_orm { namespace internal { @@ -13386,7 +13277,6 @@ namespace sqlite_orm { // #include "limit_accessor.h" - #include #include // std::map #include // std::function @@ -13394,7 +13284,6 @@ namespace sqlite_orm { // #include "connection_holder.h" - namespace sqlite_orm { namespace internal { @@ -13528,13 +13417,11 @@ namespace sqlite_orm { // #include "transaction_guard.h" - #include // std::function #include // std::move // #include "connection_holder.h" - namespace sqlite_orm { namespace internal { @@ -13561,7 +13448,7 @@ namespace sqlite_orm { connection(std::move(connection_)), commit_func(move(commit_func_)), rollback_func(move(rollback_func_)) {} - transaction_guard_t(transaction_guard_t &&other) : + transaction_guard_t(transaction_guard_t&& other) : commit_on_destroy(other.commit_on_destroy), connection(std::move(other.connection)), commit_func(move(other.commit_func)), rollback_func(move(other.rollback_func)), gotta_fire(other.gotta_fire) { @@ -13578,7 +13465,7 @@ namespace sqlite_orm { } } - transaction_guard_t &operator=(transaction_guard_t &&) = delete; + transaction_guard_t& operator=(transaction_guard_t&&) = delete; /** * Call `COMMIT` explicitly. After this call @@ -13615,7 +13502,6 @@ namespace sqlite_orm { // #include "backup.h" - #include #include // std::system_error #include // std::string @@ -13626,7 +13512,6 @@ namespace sqlite_orm { // #include "connection_holder.h" - namespace sqlite_orm { namespace internal { @@ -13694,7 +13579,6 @@ namespace sqlite_orm { // #include "values_to_tuple.h" - #include #include // std::index_sequence, std::make_index_sequence #include // std::tuple, std::tuple_size, std::get @@ -13705,19 +13589,17 @@ namespace sqlite_orm { // #include "arg_values.h" - #include // #include "row_extractor.h" - namespace sqlite_orm { struct arg_value { arg_value() : arg_value(nullptr) {} - arg_value(sqlite3_value *value_) : value(value_) {} + arg_value(sqlite3_value* value_) : value(value_) {} template T get() const { @@ -13754,18 +13636,18 @@ namespace sqlite_orm { } private: - sqlite3_value *value = nullptr; + sqlite3_value* value = nullptr; }; struct arg_values { struct iterator { - iterator(const arg_values &container_, int index_) : + iterator(const arg_values& container_, int index_) : container(container_), index(index_), currentValue(index_ < int(container_.size()) ? container_[index_] : arg_value()) {} - iterator &operator++() { + iterator& operator++() { ++this->index; if(this->index < int(this->container.size())) { this->currentValue = this->container[this->index]; @@ -13794,27 +13676,27 @@ namespace sqlite_orm { } } - arg_value *operator->() const { + arg_value* operator->() const { return &this->currentValue; } - bool operator==(const iterator &other) const { + bool operator==(const iterator& other) const { return &other.container == &this->container && other.index == this->index; } - bool operator!=(const iterator &other) const { + bool operator!=(const iterator& other) const { return !(*this == other); } private: - const arg_values &container; + const arg_values& container; int index = 0; mutable arg_value currentValue; }; arg_values() : arg_values(0, nullptr) {} - arg_values(int argsCount_, sqlite3_value **values_) : argsCount(argsCount_), values(values_) {} + arg_values(int argsCount_, sqlite3_value** values_) : argsCount(argsCount_), values(values_) {} size_t size() const { return this->argsCount; @@ -13826,7 +13708,7 @@ namespace sqlite_orm { arg_value operator[](int index) const { if(index < this->argsCount && index >= 0) { - sqlite3_value *value = this->values[index]; + sqlite3_value* value = this->values[index]; return {value}; } else { throw std::system_error{orm_error_code::index_is_out_of_bounds}; @@ -13847,11 +13729,10 @@ namespace sqlite_orm { private: int argsCount = 0; - sqlite3_value **values = nullptr; + sqlite3_value** values = nullptr; }; } - namespace sqlite_orm { namespace internal { @@ -13873,13 +13754,13 @@ namespace sqlite_orm { (this->extract(values[Idx], std::get(tuple)), ...); } #else - template - void operator()(sqlite3_value** values, Tpl& tuple, std::index_sequence) const { - this->extract(values[I], std::get(tuple)); - (*this)(values, tuple, std::index_sequence{}); - } - template - void operator()(sqlite3_value** /*values*/, Tpl&, std::index_sequence) const {} + template + void operator()(sqlite3_value** values, Tpl& tuple, std::index_sequence) const { + this->extract(values[I], std::get(tuple)); + (*this)(values, tuple, std::index_sequence{}); + } + template + void operator()(sqlite3_value** /*values*/, Tpl&, std::index_sequence) const {} #endif template void extract(sqlite3_value* value, T& t) const { @@ -13895,7 +13776,6 @@ namespace sqlite_orm { // #include "serializing_util.h" - namespace sqlite_orm { namespace internal { @@ -14662,13 +14542,11 @@ namespace sqlite_orm { // #include "expression_object_type.h" - #include // std::decay #include // std::reference_wrapper // #include "prepared_statement.h" - namespace sqlite_orm { namespace internal { @@ -14802,7 +14680,6 @@ namespace sqlite_orm { // #include "statement_serializer.h" - #include // std::stringstream #include // std::string #include // std::enable_if, std::remove_pointer @@ -14815,7 +14692,6 @@ namespace sqlite_orm { #include // #include "functional/cxx_string_view.h" - // #include "functional/cxx_universal.h" // #include "functional/cxx_functional_polyfill.h" @@ -14858,7 +14734,6 @@ namespace sqlite_orm { // #include "table_name_collector.h" - #include // std::set #include // std::string #include // std::function @@ -14874,14 +14749,13 @@ namespace sqlite_orm { // #include "core_functions.h" - namespace sqlite_orm { namespace internal { struct table_name_collector { using table_name_set = std::set>; - using find_table_name_t = std::function; + using find_table_name_t = std::function; find_table_name_t find_table_name; mutable table_name_set table_names; @@ -14891,7 +14765,7 @@ namespace sqlite_orm { table_name_collector(find_table_name_t find_table_name) : find_table_name{move(find_table_name)} {} template - table_name_set operator()(const T &) const { + table_name_set operator()(const T&) const { return {}; } @@ -14901,17 +14775,17 @@ namespace sqlite_orm { } template - void operator()(const column_pointer &) const { + void operator()(const column_pointer&) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } template - void operator()(const alias_column_t &a) const { + void operator()(const alias_column_t& a) const { (*this)(a.column, alias_extractor::get()); } template - void operator()(const count_asterisk_t &) const { + void operator()(const count_asterisk_t&) const { auto tableName = this->find_table_name(typeid(T)); if(!tableName.empty()) { table_names.emplace(move(tableName), ""); @@ -14919,12 +14793,12 @@ namespace sqlite_orm { } template = true> - void operator()(const asterisk_t &) const { + void operator()(const asterisk_t&) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } template = true> - void operator()(const asterisk_t &) const { + void operator()(const asterisk_t&) const { // note: not all alias classes have a nested A::type static_assert(polyfill::is_detected_v, "alias must have a nested alias::type typename"); @@ -14933,22 +14807,22 @@ namespace sqlite_orm { } template - void operator()(const object_t &) const { + void operator()(const object_t&) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } template - void operator()(const table_rowid_t &) const { + void operator()(const table_rowid_t&) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } template - void operator()(const table_oid_t &) const { + void operator()(const table_oid_t&) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } template - void operator()(const table__rowid_t &) const { + void operator()(const table__rowid_t&) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } }; @@ -14959,7 +14833,6 @@ namespace sqlite_orm { // #include "column_names_getter.h" - #include // std::system_error #include // std::string #include // std::vector @@ -14975,7 +14848,6 @@ namespace sqlite_orm { // #include "util.h" - namespace sqlite_orm { namespace internal { @@ -15080,7 +14952,6 @@ namespace sqlite_orm { // #include "order_by_serializer.h" - #include // std::string #include // std::stringstream @@ -15172,7 +15043,6 @@ namespace sqlite_orm { // #include "util.h" - namespace sqlite_orm { namespace internal { @@ -17203,7 +17073,6 @@ namespace sqlite_orm { // #include "serializing_util.h" - namespace sqlite_orm { namespace internal { @@ -18005,7 +17874,7 @@ namespace sqlite_orm { #if SQLITE_VERSION_NUMBER >= 3035000 // DROP COLUMN feature exists (v3.35.0) res = sync_schema_result::old_columns_removed; #else - gottaCreateTable = true; + gottaCreateTable = true; #endif } else { res = sync_schema_result::old_columns_removed; @@ -18324,13 +18193,13 @@ namespace sqlite_orm { std::ref(processObject), std::ref(expression.transformer)); #else - auto& transformer = expression.transformer; - std::for_each(expression.range.first, - expression.range.second, - [&processObject, &transformer](auto& item) { - const object_type& object = polyfill::invoke(transformer, item); - processObject(object); - }); + auto& transformer = expression.transformer; + std::for_each(expression.range.first, + expression.range.second, + [&processObject, &transformer](auto& item) { + const object_type& object = polyfill::invoke(transformer, item); + processObject(object); + }); #endif }, [&processObject](auto& expression) { @@ -18370,13 +18239,13 @@ namespace sqlite_orm { std::ref(processObject), std::ref(expression.transformer)); #else - auto& transformer = expression.transformer; - std::for_each(expression.range.first, - expression.range.second, - [&processObject, &transformer](auto& item) { - const object_type& object = polyfill::invoke(transformer, item); - processObject(object); - }); + auto& transformer = expression.transformer; + std::for_each(expression.range.first, + expression.range.second, + [&processObject, &transformer](auto& item) { + const object_type& object = polyfill::invoke(transformer, item); + processObject(object); + }); #endif }, [&processObject](auto& expression) { @@ -18468,22 +18337,22 @@ namespace sqlite_orm { } return move(res).value(); #else - auto& table = this->get_table(); - auto stepRes = sqlite3_step(stmt); - switch(stepRes) { - case SQLITE_ROW: { - T res; - object_from_column_builder builder{res, stmt}; - table.for_each_column(builder); - return res; - } break; - case SQLITE_DONE: { - throw std::system_error{orm_error_code::not_found}; - } break; - default: { - throw_translated_sqlite_error(stmt); + auto& table = this->get_table(); + auto stepRes = sqlite3_step(stmt); + switch(stepRes) { + case SQLITE_ROW: { + T res; + object_from_column_builder builder{res, stmt}; + table.for_each_column(builder); + return res; + } break; + case SQLITE_DONE: { + throw std::system_error{orm_error_code::not_found}; + } break; + default: { + throw_translated_sqlite_error(stmt); + } } - } #endif } @@ -18594,7 +18463,6 @@ namespace sqlite_orm { #include // std::reference_wrapper // #include "functional/cxx_optional.h" - // #include "tuple_helper/tuple_filter.h" // #include "conditions.h" @@ -18621,7 +18489,6 @@ namespace sqlite_orm { // #include "ast/group_by.h" - namespace sqlite_orm { namespace internal { @@ -18926,7 +18793,6 @@ namespace sqlite_orm { // #include "expression_object_type.h" - namespace sqlite_orm { template @@ -19106,7 +18972,6 @@ namespace sqlite_orm { // #include "pointer_value.h" - namespace sqlite_orm { inline constexpr const char carray_pvt_name[] = "carray"; @@ -19179,7 +19044,6 @@ namespace sqlite_orm { // #include "table.h" - namespace sqlite_orm { #ifdef SQLITE_ENABLE_DBSTAT_VTAB struct dbstat { @@ -19222,7 +19086,6 @@ namespace sqlite_orm { * this file is also used to provide definitions of interface methods 'hitting the database'. */ - #include // std::make_unique // #include "../functional/cxx_core_features.h" @@ -19239,7 +19102,6 @@ namespace sqlite_orm { // #include "../column.h" - namespace sqlite_orm { namespace internal { @@ -19279,7 +19141,6 @@ namespace sqlite_orm { // #include "../table.h" - namespace sqlite_orm { namespace internal { @@ -19307,9 +19168,9 @@ namespace sqlite_orm { #if __cpp_lib_ranges >= 201911L auto it = std::ranges::find(res, columnName, &table_xinfo::name); #else - auto it = std::find_if(res.begin(), res.end(), [&columnName](const table_xinfo& ti) { - return ti.name == columnName; - }); + auto it = std::find_if(res.begin(), res.end(), [&columnName](const table_xinfo& ti) { + return ti.name == columnName; + }); #endif if(it != res.end()) { it->pk = static_cast(i + 1); @@ -19340,7 +19201,6 @@ namespace sqlite_orm { // #include "../storage.h" - namespace sqlite_orm { namespace internal { @@ -19383,9 +19243,9 @@ namespace sqlite_orm { } res = sync_schema_result::old_columns_removed; #else - // extra table columns than storage columns - this->backup_table(db, table, {}); - res = sync_schema_result::old_columns_removed; + // extra table columns than storage columns + this->backup_table(db, table, {}); + res = sync_schema_result::old_columns_removed; #endif } @@ -19449,11 +19309,11 @@ namespace sqlite_orm { #if __cpp_lib_ranges >= 201911L auto columnToIgnoreIt = std::ranges::find(columnsToIgnore, columnName, &table_xinfo::name); #else - auto columnToIgnoreIt = std::find_if(columnsToIgnore.begin(), - columnsToIgnore.end(), - [&columnName](const table_xinfo* tableInfo) { - return columnName == tableInfo->name; - }); + auto columnToIgnoreIt = std::find_if(columnsToIgnore.begin(), + columnsToIgnore.end(), + [&columnName](const table_xinfo* tableInfo) { + return columnName == tableInfo->name; + }); #endif if(columnToIgnoreIt == columnsToIgnore.end()) { columnNames.push_back(cref(columnName)); diff --git a/tests/storage_non_crud_tests.cpp b/tests/storage_non_crud_tests.cpp index aab36cd62..1753c219f 100644 --- a/tests/storage_non_crud_tests.cpp +++ b/tests/storage_non_crud_tests.cpp @@ -587,7 +587,8 @@ TEST_CASE("Explicit insert") { SECTION("one column") { User user4; user4.name = "Egor"; - REQUIRE_THROWS_WITH(storage.insert(user4, columns(&User::name)), ContainsSubstring("NOT NULL constraint failed")); + REQUIRE_THROWS_WITH(storage.insert(user4, columns(&User::name)), + ContainsSubstring("NOT NULL constraint failed")); } } SECTION("visit") { From c21687b5695d13722971ad87484dd7be6523c8fc Mon Sep 17 00:00:00 2001 From: fnc12 Date: Wed, 9 Dec 2020 11:41:55 +0600 Subject: [PATCH 12/22] Revert "removed PointerAlignment and changer DerivePointerAlignment to true" This reverts commit c5e84c91f7b0aa0f7ceed9ba090e92eed907252e. --- .clang-format | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.clang-format b/.clang-format index 11b424a88..f4bc58fcd 100644 --- a/.clang-format +++ b/.clang-format @@ -54,7 +54,7 @@ ConstructorInitializerAllOnOneLineOrOnePerLine: false ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: true -DerivePointerAlignment: true +DerivePointerAlignment: false DisableFormat: false ExperimentalAutoDetectBinPacking: false FixNamespaceComments: false @@ -94,6 +94,7 @@ PenaltyBreakString: 1000 PenaltyBreakTemplateDeclaration: 10 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Left ReflowComments: false SortIncludes: false SortUsingDeclarations: true From 5818dac82460f769ba32a1c7df9953277ba342dc Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Mon, 16 Jan 2023 11:17:30 +0200 Subject: [PATCH 13/22] Applied new code formatting --- dev/arg_values.h | 22 ++++----- dev/function.h | 10 ++-- dev/table_name_collector.h | 22 ++++----- dev/transaction_guard.h | 4 +- dev/triggers.h | 6 +-- examples/blob_binding.cpp | 22 ++++----- examples/generated_column.cpp | 4 +- examples/triggers.cpp | 6 +-- examples/user_defined_functions.cpp | 10 ++-- tests/ast_iterator_tests.cpp | 4 +- .../math_functions.cpp | 2 +- tests/json.cpp | 4 +- tests/operators/in.cpp | 4 +- tests/prepared_statement_tests/insert.cpp | 8 ++-- .../prepared_statement_tests/insert_range.cpp | 16 +++---- tests/static_tests/column_result_t.cpp | 2 +- tests/static_tests/function_static_tests.cpp | 12 ++--- tests/storage_non_crud_tests.cpp | 22 ++++----- tests/tests2.cpp | 46 +++++++++---------- tests/tuple_iteration.cpp | 12 ++--- 20 files changed, 119 insertions(+), 119 deletions(-) diff --git a/dev/arg_values.h b/dev/arg_values.h index c9e407efe..9060460b0 100644 --- a/dev/arg_values.h +++ b/dev/arg_values.h @@ -10,7 +10,7 @@ namespace sqlite_orm { arg_value() : arg_value(nullptr) {} - arg_value(sqlite3_value *value_) : value(value_) {} + arg_value(sqlite3_value* value_) : value(value_) {} template T get() const { @@ -47,18 +47,18 @@ namespace sqlite_orm { } private: - sqlite3_value *value = nullptr; + sqlite3_value* value = nullptr; }; struct arg_values { struct iterator { - iterator(const arg_values &container_, int index_) : + iterator(const arg_values& container_, int index_) : container(container_), index(index_), currentValue(index_ < int(container_.size()) ? container_[index_] : arg_value()) {} - iterator &operator++() { + iterator& operator++() { ++this->index; if(this->index < int(this->container.size())) { this->currentValue = this->container[this->index]; @@ -87,27 +87,27 @@ namespace sqlite_orm { } } - arg_value *operator->() const { + arg_value* operator->() const { return &this->currentValue; } - bool operator==(const iterator &other) const { + bool operator==(const iterator& other) const { return &other.container == &this->container && other.index == this->index; } - bool operator!=(const iterator &other) const { + bool operator!=(const iterator& other) const { return !(*this == other); } private: - const arg_values &container; + const arg_values& container; int index = 0; mutable arg_value currentValue; }; arg_values() : arg_values(0, nullptr) {} - arg_values(int argsCount_, sqlite3_value **values_) : argsCount(argsCount_), values(values_) {} + arg_values(int argsCount_, sqlite3_value** values_) : argsCount(argsCount_), values(values_) {} size_t size() const { return this->argsCount; @@ -119,7 +119,7 @@ namespace sqlite_orm { arg_value operator[](int index) const { if(index < this->argsCount && index >= 0) { - sqlite3_value *value = this->values[index]; + sqlite3_value* value = this->values[index]; return {value}; } else { throw std::system_error{orm_error_code::index_is_out_of_bounds}; @@ -140,6 +140,6 @@ namespace sqlite_orm { private: int argsCount = 0; - sqlite3_value **values = nullptr; + sqlite3_value** values = nullptr; }; } diff --git a/dev/function.h b/dev/function.h index b1f62b50a..0462c22b3 100644 --- a/dev/function.h +++ b/dev/function.h @@ -24,13 +24,13 @@ namespace sqlite_orm { struct user_defined_function_base { using func_call = std::function< - void(sqlite3_context *context, void *functionPointer, int argsCount, sqlite3_value **values)>; - using final_call = std::function; + void(sqlite3_context* context, void* functionPointer, int argsCount, sqlite3_value** values)>; + using final_call = std::function; std::string name; int argumentsCount = 0; - std::function create; - void (*destroy)(int *) = nullptr; + std::function create; + void (*destroy)(int*) = nullptr; #ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED user_defined_function_base(decltype(name) name_, @@ -162,7 +162,7 @@ namespace sqlite_orm { constexpr bool is_same_pvt_v> = true; #if __cplusplus >= 201703L // using C++17 or higher - template + template SQLITE_ORM_CONSTEVAL bool assert_same_pointer_type() { constexpr bool valid = Binding == PointerArg; static_assert(valid, "Pointer value types of I-th argument do not match"); diff --git a/dev/table_name_collector.h b/dev/table_name_collector.h index 6e9ed8426..628f5faa0 100644 --- a/dev/table_name_collector.h +++ b/dev/table_name_collector.h @@ -17,7 +17,7 @@ namespace sqlite_orm { struct table_name_collector { using table_name_set = std::set>; - using find_table_name_t = std::function; + using find_table_name_t = std::function; find_table_name_t find_table_name; mutable table_name_set table_names; @@ -27,7 +27,7 @@ namespace sqlite_orm { table_name_collector(find_table_name_t find_table_name) : find_table_name{move(find_table_name)} {} template - table_name_set operator()(const T &) const { + table_name_set operator()(const T&) const { return {}; } @@ -37,17 +37,17 @@ namespace sqlite_orm { } template - void operator()(const column_pointer &) const { + void operator()(const column_pointer&) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } template - void operator()(const alias_column_t &a) const { + void operator()(const alias_column_t& a) const { (*this)(a.column, alias_extractor::get()); } template - void operator()(const count_asterisk_t &) const { + void operator()(const count_asterisk_t&) const { auto tableName = this->find_table_name(typeid(T)); if(!tableName.empty()) { table_names.emplace(move(tableName), ""); @@ -55,12 +55,12 @@ namespace sqlite_orm { } template = true> - void operator()(const asterisk_t &) const { + void operator()(const asterisk_t&) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } template = true> - void operator()(const asterisk_t &) const { + void operator()(const asterisk_t&) const { // note: not all alias classes have a nested A::type static_assert(polyfill::is_detected_v, "alias must have a nested alias::type typename"); @@ -69,22 +69,22 @@ namespace sqlite_orm { } template - void operator()(const object_t &) const { + void operator()(const object_t&) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } template - void operator()(const table_rowid_t &) const { + void operator()(const table_rowid_t&) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } template - void operator()(const table_oid_t &) const { + void operator()(const table_oid_t&) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } template - void operator()(const table__rowid_t &) const { + void operator()(const table__rowid_t&) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } }; diff --git a/dev/transaction_guard.h b/dev/transaction_guard.h index 831992de1..b6cd33274 100644 --- a/dev/transaction_guard.h +++ b/dev/transaction_guard.h @@ -31,7 +31,7 @@ namespace sqlite_orm { connection(std::move(connection_)), commit_func(move(commit_func_)), rollback_func(move(rollback_func_)) {} - transaction_guard_t(transaction_guard_t &&other) : + transaction_guard_t(transaction_guard_t&& other) : commit_on_destroy(other.commit_on_destroy), connection(std::move(other.connection)), commit_func(move(other.commit_func)), rollback_func(move(other.rollback_func)), gotta_fire(other.gotta_fire) { @@ -48,7 +48,7 @@ namespace sqlite_orm { } } - transaction_guard_t &operator=(transaction_guard_t &&) = delete; + transaction_guard_t& operator=(transaction_guard_t&&) = delete; /** * Call `COMMIT` explicitly. After this call diff --git a/dev/triggers.h b/dev/triggers.h index 20b18fef1..f7b95da08 100644 --- a/dev/triggers.h +++ b/dev/triggers.h @@ -40,7 +40,7 @@ namespace sqlite_orm { partial_trigger_t(T trigger_base, S... statements) : base{std::move(trigger_base)}, statements{std::make_tuple(std::forward(statements)...)} {} - partial_trigger_t &end() { + partial_trigger_t& end() { return *this; } }; @@ -109,7 +109,7 @@ namespace sqlite_orm { trigger_base_t(trigger_type_base type_base_) : type_base(std::move(type_base_)) {} - trigger_base_t &for_each_row() { + trigger_base_t& for_each_row() { this->do_for_each_row = true; return *this; } @@ -270,7 +270,7 @@ namespace sqlite_orm { } template - internal::trigger_t make_trigger(std::string name, const internal::partial_trigger_t &part) { + internal::trigger_t make_trigger(std::string name, const internal::partial_trigger_t& part) { SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(return {move(name), std::move(part.base), std::move(part.statements)}); } diff --git a/examples/blob_binding.cpp b/examples/blob_binding.cpp index ff2d8fb7b..614008b98 100644 --- a/examples/blob_binding.cpp +++ b/examples/blob_binding.cpp @@ -17,7 +17,7 @@ struct Rect { int height = 0; }; -bool operator==(const Rect &lhs, const Rect &rhs) { +bool operator==(const Rect& lhs, const Rect& rhs) { return lhs.x == rhs.x && lhs.y == rhs.y && lhs.width == rhs.width && lhs.height == rhs.height; } @@ -26,7 +26,7 @@ struct Zone { Rect rect; // this member will be mapped as BLOB column }; -bool operator==(const Zone &lhs, const Zone &rhs) { +bool operator==(const Zone& lhs, const Zone& rhs) { return lhs.id == rhs.id && lhs.rect == rhs.rect; } @@ -52,13 +52,13 @@ namespace sqlite_orm { template<> struct statement_binder { - int bind(sqlite3_stmt *stmt, int index, const Rect &value) { + int bind(sqlite3_stmt* stmt, int index, const Rect& value) { std::vector blobValue; blobValue.reserve(16); auto encodeInteger = [&blobValue](int value) { auto preciseValue = int32_t(value); const auto intPointer = &preciseValue; - auto charPointer = (const char *)(intPointer); + auto charPointer = (const char*)(intPointer); blobValue.push_back(charPointer[0]); blobValue.push_back(charPointer[1]); blobValue.push_back(charPointer[2]); @@ -78,7 +78,7 @@ namespace sqlite_orm { */ template<> struct field_printer { - std::string operator()(const Rect &value) const { + std::string operator()(const Rect& value) const { std::stringstream ss; ss << "{ x = " << value.x << ", y = " << value.y << ", width = " << value.width << ", height = " << value.height << " }"; @@ -94,13 +94,13 @@ namespace sqlite_orm { template<> struct row_extractor { - Rect extract(sqlite3_stmt *stmt, int columnIndex) { + Rect extract(sqlite3_stmt* stmt, int columnIndex) { auto blobPointer = sqlite3_column_blob(stmt, columnIndex); - auto charPointer = (const char *)blobPointer; + auto charPointer = (const char*)blobPointer; Rect value; - auto decodeInteger = [charPointer](int &integer, int index) { + auto decodeInteger = [charPointer](int& integer, int index) { auto pointerWithOffset = charPointer + index * 4; - auto intPointer = (const int32_t *)pointerWithOffset; + auto intPointer = (const int32_t*)pointerWithOffset; integer = int(*intPointer); }; decodeInteger(value.x, 0); @@ -121,7 +121,7 @@ int main() { auto allZones = storage.get_all(); cout << "zones count = " << allZones.size() << ":" << endl; // zones count = 1: - for(auto &zone: allZones) { + for(auto& zone: allZones) { cout << "zone = " << storage.dump(zone) << endl; // zone = { id : '1', rect : '{ x = 10, y = 10, width = 200, height = 300 }' } } @@ -130,7 +130,7 @@ int main() { cout << endl; allZones = storage.get_all(); cout << "zones count = " << allZones.size() << ":" << endl; // zones count = 1: - for(auto &zone: allZones) { + for(auto& zone: allZones) { cout << "zone = " << storage.dump(zone) << endl; // zone = { id : '1', rect : '{ x = 20, y = 20, width = 500, height = 600 }' } } diff --git a/examples/generated_column.cpp b/examples/generated_column.cpp index 8cc1664a9..129792ceb 100644 --- a/examples/generated_column.cpp +++ b/examples/generated_column.cpp @@ -37,7 +37,7 @@ int main() { storage.replace(Product{5, "Bandage", 70, 120.00f}); cout << "Products:" << endl; - for(auto &product: storage.iterate()) { + for(auto& product: storage.iterate()) { cout << storage.dump(product) << endl; } cout << endl; @@ -47,7 +47,7 @@ int main() { storage.update_all(set(c(&Product::quantity) = 5), where(c(&Product::id) == 1)); cout << "Products after update:" << endl; - for(auto &product: storage.iterate()) { + for(auto& product: storage.iterate()) { cout << storage.dump(product) << endl; } cout << endl; diff --git a/examples/triggers.cpp b/examples/triggers.cpp index 246127c4e..585b57bf9 100644 --- a/examples/triggers.cpp +++ b/examples/triggers.cpp @@ -147,7 +147,7 @@ int main() { // VALUES('John', 'Doe', 'jjj', '4089009334'); try { storage.insert(Lead{0, "John", "Doe", "jjj", "4089009334"}); - } catch(const std::system_error &systemError) { + } catch(const std::system_error& systemError) { cout << "error: " << systemError.what() << endl; } @@ -157,7 +157,7 @@ int main() { storage.insert(Lead{0, "John", "Doe", "john.doe@sqlitetutorial.net", "4089009334"}); cout << "Leads:" << endl; - for(auto &lead: storage.iterate()) { + for(auto& lead: storage.iterate()) { cout << storage.dump(lead) << endl; } @@ -178,7 +178,7 @@ int main() { cout << "Logs count = " << storage.count() << endl; - for(auto &leadLog: storage.iterate()) { + for(auto& leadLog: storage.iterate()) { cout << storage.dump(leadLog) << endl; } diff --git a/examples/user_defined_functions.cpp b/examples/user_defined_functions.cpp index fcc2a2b9f..d9bce0678 100644 --- a/examples/user_defined_functions.cpp +++ b/examples/user_defined_functions.cpp @@ -30,7 +30,7 @@ struct SignFunction { } } - static const char *name() { + static const char* name() { return "SIGN"; } }; @@ -72,7 +72,7 @@ struct AcceleratedSumFunction { /** * `const std::string &` is also a valid type of name cause it has `operator<<(std::ostream &` overload */ - static const std::string &name() { + static const std::string& name() { static const std::string result = "ASUM"; return result; } @@ -85,7 +85,7 @@ struct AcceleratedSumFunction { */ struct ArithmeticMeanFunction { - double operator()(const arg_values &args) const { + double operator()(const arg_values& args) const { double result = 0; for(auto arg_value: args) { if(arg_value.is_float()) { @@ -100,7 +100,7 @@ struct ArithmeticMeanFunction { return result; } - static const std::string &name() { + static const std::string& name() { static const std::string result = "ARITHMETIC_MEAN"; return result; } @@ -142,7 +142,7 @@ int main() { func(&Table::b), func(&Table::c))); cout << "SELECT ASUM(a), ASUM(b), ASUM(c) FROM t:" << endl; - for(auto &row: aSumRows) { + for(auto& row: aSumRows) { cout << '\t' << get<0>(row) << endl; cout << '\t' << get<1>(row) << endl; cout << '\t' << get<2>(row) << endl; diff --git a/tests/ast_iterator_tests.cpp b/tests/ast_iterator_tests.cpp index 761548e4d..9f04b377b 100644 --- a/tests/ast_iterator_tests.cpp +++ b/tests/ast_iterator_tests.cpp @@ -10,7 +10,7 @@ TEST_CASE("ast_iterator") { }; std::vector typeIndexes; decltype(typeIndexes) expected; - auto lambda = [&typeIndexes](auto &value) { + auto lambda = [&typeIndexes](auto& value) { typeIndexes.push_back(typeid(value)); }; SECTION("bindables") { @@ -169,7 +169,7 @@ TEST_CASE("ast_iterator") { } SECTION("bindable") { auto node = order_by(""); - expected.push_back(typeid(const char *)); + expected.push_back(typeid(const char*)); internal::iterate_ast(node, lambda); } SECTION("positional ordinal") { diff --git a/tests/built_in_functions_tests/math_functions.cpp b/tests/built_in_functions_tests/math_functions.cpp index 47d9df290..eb8ee7eea 100644 --- a/tests/built_in_functions_tests/math_functions.cpp +++ b/tests/built_in_functions_tests/math_functions.cpp @@ -15,7 +15,7 @@ TEST_CASE("math functions") { auto storage = make_storage(""); auto doubleComparator = std::bind(is_double_eq, _1, _2, Epsilon); #ifdef SQLITE_ORM_OPTIONAL_SUPPORTED - auto optionalComparator = [](const std::optional &lhs, const std::optional &rhs) { + auto optionalComparator = [](const std::optional& lhs, const std::optional& rhs) { if(lhs.has_value() && rhs.has_value()) { return is_double_eq(*lhs, *rhs, Epsilon); } else if(!lhs.has_value() && !rhs.has_value()) { diff --git a/tests/json.cpp b/tests/json.cpp index 1f5769782..88534489d 100644 --- a/tests/json.cpp +++ b/tests/json.cpp @@ -375,7 +375,7 @@ TEST_CASE("json_type") { testCases.push_back(TestCase{R"({"a":[2,3.5,true,false,null,"x"]})", "null", "$.a[4]"}); testCases.push_back(TestCase{R"({"a":[2,3.5,true,false,null,"x"]})", "text", "$.a[5]"}); testCases.push_back(TestCase{R"({"a":[2,3.5,true,false,null,"x"]})", "", "$.a[6]"}); - for(auto &testCase: testCases) { + for(auto& testCase: testCases) { { auto rows = storage.select(json_type(testCase.argument, testCase.secondArgument)); decltype(rows) expected; @@ -406,7 +406,7 @@ TEST_CASE("json_valid") { std::vector testCases; testCases.push_back(TestCase{R"({"x":35})", true}); testCases.push_back(TestCase{R"({"x":35)", false}); - for(auto &testCase: testCases) { + for(auto& testCase: testCases) { auto rows = storage.select(json_valid(testCase.argument)); decltype(rows) expected; expected.push_back(testCase.expected); diff --git a/tests/operators/in.cpp b/tests/operators/in.cpp index e48b1a93a..2997403fa 100644 --- a/tests/operators/in.cpp +++ b/tests/operators/in.cpp @@ -14,11 +14,11 @@ TEST_CASE("In") { User(int id) : id{id} {} #endif - bool operator==(const User &other) const { + bool operator==(const User& other) const { return this->id == other.id; } - std::ostream &operator<<(std::ostream &os) const { + std::ostream& operator<<(std::ostream& os) const { return os << this->id; } }; diff --git a/tests/prepared_statement_tests/insert.cpp b/tests/prepared_statement_tests/insert.cpp index 087a3dc87..8a5d88835 100644 --- a/tests/prepared_statement_tests/insert.cpp +++ b/tests/prepared_statement_tests/insert.cpp @@ -17,14 +17,14 @@ TEST_CASE("Prepared insert") { Artist(decltype(id) id_, decltype(name) name_) : id(id_), name(move(name_)) {} - Artist(const Artist &other) : + Artist(const Artist& other) : id(other.id), name(other.name ? std::make_unique(*other.name) : nullptr) {} - bool operator==(const Artist &other) const { + bool operator==(const Artist& other) const { return this->id == other.id && this->compareNames(this->name, other.name); } - bool compareNames(const decltype(name) &lhs, const decltype(name) &rhs) const { + bool compareNames(const decltype(name)& lhs, const decltype(name)& rhs) const { if(lhs && rhs) { return *lhs == *rhs; } else if(!lhs && !rhs) { @@ -172,7 +172,7 @@ TEST_CASE("Prepared insert") { } REQUIRE(insertedId == 4); user.name = "Sia"; - std::ignore = get<0>(static_cast(statement)); + std::ignore = get<0>(static_cast(statement)); REQUIRE(get<0>(statement) == user); REQUIRE(&get<0>(statement) == &user); insertedId = storage.execute(statement); diff --git a/tests/prepared_statement_tests/insert_range.cpp b/tests/prepared_statement_tests/insert_range.cpp index 388d22ba8..7cfb1187c 100644 --- a/tests/prepared_statement_tests/insert_range.cpp +++ b/tests/prepared_statement_tests/insert_range.cpp @@ -70,7 +70,7 @@ TEST_CASE("Prepared insert range") { SECTION("container of pointers") { std::vector> usersPointers; usersPointers.reserve(users.size()); - std::transform(users.begin(), users.end(), std::back_inserter(usersPointers), [](const User &user) { + std::transform(users.begin(), users.end(), std::back_inserter(usersPointers), [](const User& user) { return std::make_unique(user); }); auto statement = storage.prepare( @@ -98,19 +98,19 @@ TEST_CASE("Prepared insert range") { decltype(users) otherUsers; otherUsers.push_back(User{6, "DJ Alban"}); otherUsers.push_back(User{7, "Flo Rida"}); - for(auto &user: otherUsers) { + for(auto& user: otherUsers) { expected.push_back(user); } get<0>(statement) = otherUsers.begin(); get<1>(statement) = otherUsers.end(); storage.execute(statement); - std::ignore = get<0>(static_cast(statement)); - std::ignore = get<1>(static_cast(statement)); + std::ignore = get<0>(static_cast(statement)); + std::ignore = get<1>(static_cast(statement)); } SECTION("container of pointers") { std::vector> usersPointers; - std::transform(users.begin(), users.end(), std::back_inserter(usersPointers), [](const User &user) { + std::transform(users.begin(), users.end(), std::back_inserter(usersPointers), [](const User& user) { return std::make_unique(user); }); auto statement = storage.prepare( @@ -124,15 +124,15 @@ TEST_CASE("Prepared insert range") { decltype(usersPointers) otherUsers; otherUsers.emplace_back(new User{6, "DJ Alban"}); otherUsers.emplace_back(new User{7, "Flo Rida"}); - for(auto &user: otherUsers) { + for(auto& user: otherUsers) { expected.push_back(*user); } get<0>(statement) = otherUsers.begin(); get<1>(statement) = otherUsers.end(); storage.execute(statement); - std::ignore = get<0>(static_cast(statement)); - std::ignore = get<1>(static_cast(statement)); + std::ignore = get<0>(static_cast(statement)); + std::ignore = get<1>(static_cast(statement)); } } auto rows = storage.get_all(); diff --git a/tests/static_tests/column_result_t.cpp b/tests/static_tests/column_result_t.cpp index d933a13d7..a40d32df2 100644 --- a/tests/static_tests/column_result_t.cpp +++ b/tests/static_tests/column_result_t.cpp @@ -29,7 +29,7 @@ TEST_CASE("column_result_t") { this->comment = move(comment); } - const std::string &getComment() const { + const std::string& getComment() const { return this->comment; } diff --git a/tests/static_tests/function_static_tests.cpp b/tests/static_tests/function_static_tests.cpp index a3989631a..00a3d5aa2 100644 --- a/tests/static_tests/function_static_tests.cpp +++ b/tests/static_tests/function_static_tests.cpp @@ -10,7 +10,7 @@ TEST_CASE("function static") { SECTION("scalar") { SECTION("variadic") { struct FirstFunction { - std::string operator()(const arg_values &args) const { + std::string operator()(const arg_values& args) const { std::string res; res.reserve(args.size()); for(auto value: args) { @@ -22,7 +22,7 @@ TEST_CASE("function static") { return res; } - static const char *name() { + static const char* name() { return "FIRST"; } }; @@ -118,7 +118,7 @@ TEST_CASE("function static") { } SECTION("std::string(const std::string &, const std::string &) const") { struct Function { - std::string operator()(const std::string &arg1, const std::string &arg2) const { + std::string operator()(const std::string& arg1, const std::string& arg2) const { return arg1 + arg2; } }; @@ -127,7 +127,7 @@ TEST_CASE("function static") { STATIC_REQUIRE(!is_aggregate_function_v); using RunMemberFunctionPointer = internal::scalar_call_function_t; - using ExpectedType = std::string (Function::*)(const std::string &, const std::string &) const; + using ExpectedType = std::string (Function::*)(const std::string&, const std::string&) const; STATIC_REQUIRE(std::is_same::value); using ArgumentsTuple = internal::member_function_arguments::tuple_type; @@ -140,7 +140,7 @@ TEST_CASE("function static") { } SECTION("std::string(const std::string &, const std::string &)") { struct Function { - std::string operator()(const std::string &arg1, const std::string &arg2) { + std::string operator()(const std::string& arg1, const std::string& arg2) { return arg1 + arg2; } }; @@ -149,7 +149,7 @@ TEST_CASE("function static") { STATIC_REQUIRE(!is_aggregate_function_v); using RunMemberFunctionPointer = internal::scalar_call_function_t; - using ExpectedType = std::string (Function::*)(const std::string &, const std::string &); + using ExpectedType = std::string (Function::*)(const std::string&, const std::string&); STATIC_REQUIRE(std::is_same::value); using ArgumentsTuple = internal::member_function_arguments::tuple_type; diff --git a/tests/storage_non_crud_tests.cpp b/tests/storage_non_crud_tests.cpp index 1753c219f..90f8486e7 100644 --- a/tests/storage_non_crud_tests.cpp +++ b/tests/storage_non_crud_tests.cpp @@ -185,7 +185,7 @@ TEST_CASE("InsertRange") { } TEST_CASE("Select") { - sqlite3 *db; + sqlite3* db; auto dbFileName = "test.db"; auto rc = sqlite3_open(dbFileName, &db); REQUIRE(rc == SQLITE_OK); @@ -196,11 +196,11 @@ TEST_CASE("Select") { "AFTER_WORD TEXT NOT NULL," "OCCURANCES INT NOT NULL);"; - char *errMsg = nullptr; + char* errMsg = nullptr; rc = sqlite3_exec(db, sql, nullptr, nullptr, &errMsg); REQUIRE(rc == SQLITE_OK); - sqlite3_stmt *stmt; + sqlite3_stmt* stmt; // delete previous words. This command is excess in travis or other docker based CI tools // but it is required on local machine @@ -263,9 +263,9 @@ TEST_CASE("Select") { throw std::runtime_error(sqlite3_errmsg(db)); } REQUIRE(sqlite3_column_int(stmt, 0) == firstId); - REQUIRE(::strcmp((const char *)sqlite3_column_text(stmt, 1), "best") == 0); - REQUIRE(::strcmp((const char *)sqlite3_column_text(stmt, 2), "behaviour") == 0); - REQUIRE(::strcmp((const char *)sqlite3_column_text(stmt, 3), "hey") == 0); + REQUIRE(::strcmp((const char*)sqlite3_column_text(stmt, 1), "best") == 0); + REQUIRE(::strcmp((const char*)sqlite3_column_text(stmt, 2), "behaviour") == 0); + REQUIRE(::strcmp((const char*)sqlite3_column_text(stmt, 3), "hey") == 0); REQUIRE(sqlite3_column_int(stmt, 4) == 5); sqlite3_finalize(stmt); } @@ -311,7 +311,7 @@ TEST_CASE("Select") { REQUIRE(rawTuples.size() == 1); { - auto &firstTuple = rawTuples.front(); + auto& firstTuple = rawTuples.front(); REQUIRE(std::get<0>(firstTuple) == firstId); REQUIRE(std::get<1>(firstTuple) == "best"); REQUIRE(std::get<2>(firstTuple) == "behaviour"); @@ -323,7 +323,7 @@ TEST_CASE("Select") { REQUIRE(rawTuples.size() == 1); { - auto &secondTuple = rawTuples.front(); + auto& secondTuple = rawTuples.front(); REQUIRE(std::get<0>(secondTuple) == secondId); REQUIRE(std::get<1>(secondTuple) == "corruption"); REQUIRE(std::get<2>(secondTuple) == "blood"); @@ -509,7 +509,7 @@ TEST_CASE("Explicit insert") { class Visit { public: - const int &id() const { + const int& id() const { return _id; } @@ -517,7 +517,7 @@ TEST_CASE("Explicit insert") { _id = newValue; } - const time_t &createdAt() const { + const time_t& createdAt() const { return _createdAt; } @@ -525,7 +525,7 @@ TEST_CASE("Explicit insert") { _createdAt = newValue; } - const int &usedId() const { + const int& usedId() const { return _usedId; } diff --git a/tests/tests2.cpp b/tests/tests2.cpp index 2ae6a1ece..e69ddfd02 100644 --- a/tests/tests2.cpp +++ b/tests/tests2.cpp @@ -82,7 +82,7 @@ TEST_CASE("insert with generated column") { name{move(name)}, price{price}, discount{discount}, tax{tax}, netPrice{netPrice} {} #endif - bool operator==(const Product &other) const { + bool operator==(const Product& other) const { return this->name == other.name && this->price == other.price && this->discount == other.discount && this->tax == other.tax && this->netPrice == other.netPrice; } @@ -171,7 +171,7 @@ TEST_CASE("insert") { SECTION("pointers") { std::vector> pointers; pointers.reserve(initList.size()); - std::transform(initList.begin(), initList.end(), std::back_inserter(pointers), [](const Object &object) { + std::transform(initList.begin(), initList.end(), std::back_inserter(pointers), [](const Object& object) { return std::make_unique(Object{object}); }); storage.insert_range(pointers.begin(), pointers.end(), &std::unique_ptr::operator*); @@ -197,7 +197,7 @@ struct SqrtFunction { return std::sqrt(arg); } - static const char *name() { + static const char* name() { return "SQRT_CUSTOM"; } }; @@ -212,11 +212,11 @@ struct HasPrefixFunction { ++objectsCount; } - HasPrefixFunction(const HasPrefixFunction &) { + HasPrefixFunction(const HasPrefixFunction&) { ++objectsCount; } - HasPrefixFunction(HasPrefixFunction &&) { + HasPrefixFunction(HasPrefixFunction&&) { ++objectsCount; } @@ -224,7 +224,7 @@ struct HasPrefixFunction { --objectsCount; } - bool operator()(const std::string &str, const std::string &prefix) { + bool operator()(const std::string& str, const std::string& prefix) { ++callsCount; return str.compare(0, prefix.size(), prefix) == 0; } @@ -247,11 +247,11 @@ struct MeanFunction { ++objectsCount; } - MeanFunction(const MeanFunction &) { + MeanFunction(const MeanFunction&) { ++objectsCount; } - MeanFunction(MeanFunction &&) { + MeanFunction(MeanFunction&&) { ++objectsCount; } @@ -283,11 +283,11 @@ struct FirstFunction { ++objectsCount; } - FirstFunction(const MeanFunction &) { + FirstFunction(const MeanFunction&) { ++objectsCount; } - FirstFunction(MeanFunction &&) { + FirstFunction(MeanFunction&&) { ++objectsCount; } @@ -295,7 +295,7 @@ struct FirstFunction { --objectsCount; } - std::string operator()(const arg_values &args) const { + std::string operator()(const arg_values& args) const { ++callsCount; std::string res; res.reserve(args.size()); @@ -308,7 +308,7 @@ struct FirstFunction { return res; } - static const char *name() { + static const char* name() { return "FIRST"; } }; @@ -322,11 +322,11 @@ struct MultiSum { ++objectsCount; } - MultiSum(const MeanFunction &) { + MultiSum(const MeanFunction&) { ++objectsCount; } - MultiSum(MeanFunction &&) { + MultiSum(MeanFunction&&) { ++objectsCount; } @@ -334,7 +334,7 @@ struct MultiSum { --objectsCount; } - void step(const arg_values &args) { + void step(const arg_values& args) { for(auto it = args.begin(); it != args.end(); ++it) { if(!it->empty() && (it->is_integer() || it->is_float())) { this->sum += it->get(); @@ -346,7 +346,7 @@ struct MultiSum { return this->sum; } - static const char *name() { + static const char* name() { return "MULTI_SUM"; } }; @@ -497,7 +497,7 @@ TEST_CASE("custom functions") { // Wrap std::default_delete in a function #ifndef SQLITE_ORM_BROKEN_VARIADIC_PACK_EXPANSION template -void delete_default(std::conditional_t::value, std::decay_t, T *> o) noexcept( +void delete_default(std::conditional_t::value, std::decay_t, T*> o) noexcept( noexcept(std::default_delete{}(o))) { std::default_delete{}(o); } @@ -528,7 +528,7 @@ TEST_CASE("obtain_xdestroy_for") { // class yielding a function pointer not of type xdestroy_fn_t struct int_destroy_holder { - using destroy_fn_t = void (*)(int *); + using destroy_fn_t = void (*)(int*); destroy_fn_t destroy = nullptr; @@ -538,10 +538,10 @@ TEST_CASE("obtain_xdestroy_for") { }; { - constexpr int *int_nullptr = nullptr; + constexpr int* int_nullptr = nullptr; #if !defined(SQLITE_ORM_BROKEN_VARIADIC_PACK_EXPANSION) || \ (__cpp_constexpr >= 201907L) // Trivial default initialization in constexpr functions - constexpr const int *const_int_nullptr = nullptr; + constexpr const int* const_int_nullptr = nullptr; #endif // null_xdestroy_f(int*) @@ -561,14 +561,14 @@ TEST_CASE("obtain_xdestroy_for") { #if __cpp_constexpr >= 201603L // constexpr lambda // [](void* p){} - constexpr auto lambda4_1 = [](void *) {}; + constexpr auto lambda4_1 = [](void*) {}; constexpr xdestroy_fn_t xDestroy4_1 = obtain_xdestroy_for(lambda4_1, int_nullptr); STATIC_REQUIRE(xDestroy4_1 == lambda4_1); REQUIRE(xDestroy4_1 == lambda4_1); #else #if !defined(_MSC_VER) || (_MSC_VER >= 1914) // conversion of lambda closure to function pointer using `+` // [](void* p){} - auto lambda4_1 = [](void *) {}; + auto lambda4_1 = [](void*) {}; xdestroy_fn_t xDestroy4_1 = obtain_xdestroy_for(lambda4_1, int_nullptr); REQUIRE(xDestroy4_1 == lambda4_1); #endif @@ -576,7 +576,7 @@ TEST_CASE("obtain_xdestroy_for") { // [](int* p) { delete p; } #if __cplusplus >= 202002L // default-constructible non-capturing lambdas - constexpr auto lambda4_2 = [](int *p) { + constexpr auto lambda4_2 = [](int* p) { delete p; }; using lambda4_2_t = std::remove_const_t; diff --git a/tests/tuple_iteration.cpp b/tests/tuple_iteration.cpp index 95d916250..a08c92881 100644 --- a/tests/tuple_iteration.cpp +++ b/tests/tuple_iteration.cpp @@ -12,7 +12,7 @@ TEST_CASE("tuple iteration") { std::vector expected; std::vector types; SECTION("iterate_tuple with tuple instance") { - auto lambda = [&types](const auto &item) { + auto lambda = [&types](const auto& item) { types.emplace_back(typeid(item)); }; SECTION("empty") { @@ -37,7 +37,7 @@ TEST_CASE("tuple iteration") { } } SECTION("iterate_tuple with no tuple instance") { - auto lambda = [&types](auto *itemPointer) { + auto lambda = [&types](auto* itemPointer) { using Item = std::remove_pointer_t; types.emplace_back(typeid(Item)); }; @@ -67,15 +67,15 @@ TEST_CASE("creation from tuple") { REQUIRE_THAT(strings, Equals(expected)); } SECTION("projected") { - std::vector expected{get<0>(tpl).c_str(), get<1>(tpl).c_str()}; - auto strings = create_from_tuple>(tpl, &std::string::c_str); + std::vector expected{get<0>(tpl).c_str(), get<1>(tpl).c_str()}; + auto strings = create_from_tuple>(tpl, &std::string::c_str); REQUIRE_THAT(strings, Equals(expected)); } SECTION("index selection") { constexpr size_t selectedIdx = 1; - std::vector expected{get(tpl).c_str()}; + std::vector expected{get(tpl).c_str()}; auto strings = - create_from_tuple>(tpl, std::index_sequence{}, &std::string::c_str); + create_from_tuple>(tpl, std::index_sequence{}, &std::string::c_str); REQUIRE_THAT(strings, Equals(expected)); } } From 16720e31760070f25f10fe0945ff6b3513d3bf91 Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Mon, 16 Jan 2023 12:26:27 +0200 Subject: [PATCH 14/22] Updated clang-format lint action --- .github/workflows/clang-format-lint.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clang-format-lint.yaml b/.github/workflows/clang-format-lint.yaml index d7e6488ef..3916bbbff 100644 --- a/.github/workflows/clang-format-lint.yaml +++ b/.github/workflows/clang-format-lint.yaml @@ -9,6 +9,6 @@ jobs: steps: - uses: actions/checkout@v1 - name: clang-format lint - uses: DoozyX/clang-format-lint-action@v0.12 + uses: DoozyX/clang-format-lint-action@v0.15 with: - clangFormatVersion: 12 + clangFormatVersion: 15 From b15409a63c525bc6bb85a7c31a4e41473def0155 Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Mon, 16 Jan 2023 14:08:54 +0200 Subject: [PATCH 15/22] Updated Catch2 dependency handling --- appveyor.yml | 7 ++++--- dependencies/CMakeLists.txt | 10 ++++------ dependencies/catch2/CMakeLists.txt | 2 +- dependencies/sqlite3/CMakeLists.txt | 2 +- tests/CMakeLists.txt | 2 ++ 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 0b8eea9cc..6524ca616 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -101,7 +101,8 @@ for: popd C:\Tools\vcpkg\bootstrap-vcpkg.bat -disableMetrics C:\Tools\vcpkg\vcpkg integrate install - vcpkg install sqlite3:%platform%-windows + set VCPKG_DEFAULT_TRIPLET=%platform%-windows + vcpkg install sqlite3 catch2 before_build: - |- mkdir compile @@ -130,7 +131,7 @@ for: popd $HOME/vcpkg/bootstrap-vcpkg.sh -disableMetrics $HOME/vcpkg/vcpkg integrate install --overlay-triplets=vcpkg/triplets - vcpkg install sqlite3 --overlay-triplets=vcpkg/triplets + vcpkg install sqlite3 catch2 --overlay-triplets=vcpkg/triplets before_build: - |- mkdir compile @@ -156,7 +157,7 @@ for: git clone --depth 1 --branch 2023.01.09 https://github.com/microsoft/vcpkg.git $HOME/vcpkg $HOME/vcpkg/bootstrap-vcpkg.sh -disableMetrics $HOME/vcpkg/vcpkg integrate install --overlay-triplets=vcpkg/triplets - vcpkg install sqlite3 --overlay-triplets=vcpkg/triplets + vcpkg install sqlite3 catch2 --overlay-triplets=vcpkg/triplets before_build: - |- mkdir compile diff --git a/dependencies/CMakeLists.txt b/dependencies/CMakeLists.txt index 7078b1bd3..c9ee443c0 100644 --- a/dependencies/CMakeLists.txt +++ b/dependencies/CMakeLists.txt @@ -2,13 +2,11 @@ include(FetchContent) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) FetchContent_Declare( - catch2 + Catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2.git - GIT_TAG v2.13.2 + GIT_TAG v3.2.1 ) -endif() - -if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) add_subdirectory(catch2) endif() -add_subdirectory(sqlite3) \ No newline at end of file + +add_subdirectory(sqlite3) diff --git a/dependencies/catch2/CMakeLists.txt b/dependencies/catch2/CMakeLists.txt index efbcfd8af..ea8cd9518 100644 --- a/dependencies/catch2/CMakeLists.txt +++ b/dependencies/catch2/CMakeLists.txt @@ -1 +1 @@ -FetchContent_MakeAvailable(catch2) +FetchContent_MakeAvailable(Catch2) diff --git a/dependencies/sqlite3/CMakeLists.txt b/dependencies/sqlite3/CMakeLists.txt index 028c757ed..924d5feae 100644 --- a/dependencies/sqlite3/CMakeLists.txt +++ b/dependencies/sqlite3/CMakeLists.txt @@ -1,2 +1,2 @@ # find_package exposes targets only globally, but caches them. So call find_package again in the directory of usage -find_package(SQLite3 REQUIRED) \ No newline at end of file +find_package(SQLite3 REQUIRED) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 69e491383..93668e81f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required (VERSION 3.2) +find_package(Catch2 3 CONFIG REQUIRED) + option(SQLITE_ORM_OMITS_CODECVT "Omits codec testing" OFF) add_executable(unit_tests From 848e54ddf1d2049b20c59c50c546615c9a81ebb4 Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Mon, 16 Jan 2023 16:04:49 +0200 Subject: [PATCH 16/22] Remove dangling submodule path Addressed issue #1107 --- tests/_deps/catch2-src | 1 - 1 file changed, 1 deletion(-) delete mode 160000 tests/_deps/catch2-src diff --git a/tests/_deps/catch2-src b/tests/_deps/catch2-src deleted file mode 160000 index 87074da73..000000000 --- a/tests/_deps/catch2-src +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 87074da73ecb1c2e7c35fd14f50ca21c4c002adc From 5ab49311d36caa9b60236f9f2ad931ddc408fc90 Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Mon, 16 Jan 2023 16:23:05 +0200 Subject: [PATCH 17/22] Corrected grammar in documentation for concepts --- dev/xdestroy_handling.h | 6 +++--- include/sqlite_orm/sqlite_orm.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dev/xdestroy_handling.h b/dev/xdestroy_handling.h index 25e172a32..75b89c6bb 100644 --- a/dev/xdestroy_handling.h +++ b/dev/xdestroy_handling.h @@ -19,13 +19,13 @@ namespace sqlite_orm { namespace internal { #ifdef SQLITE_ORM_CONCEPTS_SUPPORTED /** - * Constraints a deleter to be state-less. + * Constrains a deleter to be state-less. */ template concept stateless_deleter = std::is_empty_v && std::is_default_constructible_v; /** - * Constraints a deleter to be an integral function constant. + * Constrains a deleter to be an integral function constant. */ template concept integral_fp_c = requires { @@ -35,7 +35,7 @@ namespace sqlite_orm { }; /** - * Constraints a deleter to be or to yield a function pointer. + * Constrains a deleter to be or to yield a function pointer. */ template concept yields_fp = requires(D d) { diff --git a/include/sqlite_orm/sqlite_orm.h b/include/sqlite_orm/sqlite_orm.h index dfb758807..ddf40f57c 100644 --- a/include/sqlite_orm/sqlite_orm.h +++ b/include/sqlite_orm/sqlite_orm.h @@ -7494,13 +7494,13 @@ namespace sqlite_orm { namespace internal { #ifdef SQLITE_ORM_CONCEPTS_SUPPORTED /** - * Constraints a deleter to be state-less. + * Constrains a deleter to be state-less. */ template concept stateless_deleter = std::is_empty_v && std::is_default_constructible_v; /** - * Constraints a deleter to be an integral function constant. + * Constrains a deleter to be an integral function constant. */ template concept integral_fp_c = requires { @@ -7510,7 +7510,7 @@ namespace sqlite_orm { }; /** - * Constraints a deleter to be or to yield a function pointer. + * Constrains a deleter to be or to yield a function pointer. */ template concept yields_fp = requires(D d) { From 1116c835ee3b31eb076ad2c0d6289952e6a2faad Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Mon, 23 Jan 2023 19:15:39 +0200 Subject: [PATCH 18/22] Another attempt to bootstrap vcpkg on windows --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 6524ca616..c90f1944e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -98,8 +98,8 @@ for: - |- pushd C:\Tools\vcpkg git fetch --tags && git checkout 2023.01.09 + .\bootstrap-vcpkg.bat -disableMetrics popd - C:\Tools\vcpkg\bootstrap-vcpkg.bat -disableMetrics C:\Tools\vcpkg\vcpkg integrate install set VCPKG_DEFAULT_TRIPLET=%platform%-windows vcpkg install sqlite3 catch2 From 2bdb84c45602de20c0c0c930224214210eb34939 Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Mon, 23 Jan 2023 22:56:17 +0200 Subject: [PATCH 19/22] Another attempt to bootstrap vcpkg on windows --- appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index c90f1944e..3e2b73ada 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -96,10 +96,10 @@ for: if "%appveyor_build_worker_image%"=="Visual Studio 2015" (set generator="Visual Studio 14 2015" %architecture%) install: - |- - pushd C:\Tools\vcpkg + cd C:\Tools\vcpkg git fetch --tags && git checkout 2023.01.09 - .\bootstrap-vcpkg.bat -disableMetrics - popd + cd %APPVEYOR_BUILD_FOLDER% + C:\Tools\vcpkg\vcpkg\bootstrap-vcpkg.bat -disableMetrics C:\Tools\vcpkg\vcpkg integrate install set VCPKG_DEFAULT_TRIPLET=%platform%-windows vcpkg install sqlite3 catch2 From 9ed4f4cbd7580f960e6de155bc5ec4c7d94d757a Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Tue, 24 Jan 2023 09:07:42 +0200 Subject: [PATCH 20/22] Fixed stupid mistake in appveyor build path --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 3e2b73ada..753fbc05e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -99,7 +99,7 @@ for: cd C:\Tools\vcpkg git fetch --tags && git checkout 2023.01.09 cd %APPVEYOR_BUILD_FOLDER% - C:\Tools\vcpkg\vcpkg\bootstrap-vcpkg.bat -disableMetrics + C:\Tools\vcpkg\bootstrap-vcpkg.bat -disableMetrics C:\Tools\vcpkg\vcpkg integrate install set VCPKG_DEFAULT_TRIPLET=%platform%-windows vcpkg install sqlite3 catch2 From 785868c46f5a502e32866ea2bec65d2916591ca1 Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Tue, 24 Jan 2023 10:27:48 +0200 Subject: [PATCH 21/22] Try C++14 with Visual Studio 2022 instead of Visual Studio 2015 Update 3 --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 753fbc05e..7eb6d8551 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -33,8 +33,8 @@ environment: SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_14=ON" # Representative for C++14 - - job_name: Visual Studio 2015 Update 3, x64, C++14 - appveyor_build_worker_image: Visual Studio 2015 + - job_name: Visual Studio 2022, x64, C++14 + appveyor_build_worker_image: Visual Studio 2022 platform: x64 SQLITE_ORM_CXX_STANDARD: "" From a4c4e6bda0af8de038e857f5d27dd016583f3a22 Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Tue, 24 Jan 2023 15:14:50 +0200 Subject: [PATCH 22/22] Runner-up: Conformance fallback for NSMDI Amends commit 7bb1a393addb06771ea7d98dbcb29a54ab86862b --- examples/blob_binding.cpp | 10 ++++++ examples/case.cpp | 6 ++++ examples/check.cpp | 12 +++++++ examples/column_aliases.cpp | 6 ++++ examples/core_functions.cpp | 33 +++++++++++++++++++ examples/custom_aliases.cpp | 11 +++++++ examples/except_intersection.cpp | 16 +++++++++ examples/generated_column.cpp | 6 ++++ examples/prepared_statement.cpp | 18 ++++++++++ examples/triggers.cpp | 6 ++++ examples/user_defined_functions.cpp | 5 +++ .../statements/insert_replace.cpp | 2 +- 12 files changed, 130 insertions(+), 1 deletion(-) diff --git a/examples/blob_binding.cpp b/examples/blob_binding.cpp index 614008b98..3979f1cff 100644 --- a/examples/blob_binding.cpp +++ b/examples/blob_binding.cpp @@ -15,6 +15,11 @@ struct Rect { int y = 0; int width = 0; int height = 0; + +#ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED + Rect() = default; + Rect(int x, int y, int width, int height) : x{x}, y{y}, width{width}, height{height} {} +#endif }; bool operator==(const Rect& lhs, const Rect& rhs) { @@ -24,6 +29,11 @@ bool operator==(const Rect& lhs, const Rect& rhs) { struct Zone { int id = 0; Rect rect; // this member will be mapped as BLOB column + +#ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED + Zone() = default; + Zone(int id, Rect rect) : id{id}, rect{rect} {} +#endif }; bool operator==(const Zone& lhs, const Zone& rhs) { diff --git a/examples/case.cpp b/examples/case.cpp index f2e0d6a14..ef0dbd6cd 100644 --- a/examples/case.cpp +++ b/examples/case.cpp @@ -15,6 +15,12 @@ int main() { std::string name; std::string email; float marks = 0; + +#ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED + Student() {} + Student(int id, std::string name, std::string email, float marks) : + id{id}, name{move(name)}, email{move(email)}, marks{marks} {} +#endif }; auto storage = make_storage({}, diff --git a/examples/check.cpp b/examples/check.cpp index f6b2841f0..e6e74fc72 100644 --- a/examples/check.cpp +++ b/examples/check.cpp @@ -13,6 +13,12 @@ int main() { std::string lastName; std::string email; std::string phone; + +#ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED + Contact() {} + Contact(int id, std::string firstName, std::string lastName, std::string email, std::string phone) : + id{id}, firstName{move(firstName)}, lastName{move(lastName)}, email{move(email)}, phone{move(phone)} {} +#endif }; struct Product { @@ -20,6 +26,12 @@ int main() { std::string name; float listPrice = 0; float discount = 0; + +#ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED + Product() {} + Product(int id, std::string name, float listPrice, float discount) : + id{id}, name{move(name)}, listPrice{listPrice}, discount{discount} {} +#endif }; auto storage = make_storage(":memory:", diff --git a/examples/column_aliases.cpp b/examples/column_aliases.cpp index 671809829..7a9cad26f 100644 --- a/examples/column_aliases.cpp +++ b/examples/column_aliases.cpp @@ -13,6 +13,12 @@ void marvel_hero_ordered_by_o_pos() { std::string name; std::string abilities; short points = 0; + +#ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED + MarvelHero() {} + MarvelHero(int id, std::string name, std::string abilities, short points) : + id{id}, name{move(name)}, abilities{move(abilities)}, points{points} {} +#endif }; auto storage = make_storage("", diff --git a/examples/core_functions.cpp b/examples/core_functions.cpp index 864d92dbf..9a6520223 100644 --- a/examples/core_functions.cpp +++ b/examples/core_functions.cpp @@ -10,6 +10,12 @@ struct MarvelHero { std::string name; std::string abilities; short points = 0; + +#ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED + MarvelHero() {} + MarvelHero(int id, std::string name, std::string abilities, short points) : + id{id}, name{move(name)}, abilities{move(abilities)}, points{points} {} +#endif }; struct Contact { @@ -17,6 +23,12 @@ struct Contact { std::string firstName; std::string lastName; std::string phone; + +#ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED + Contact() {} + Contact(int id, std::string firstName, std::string lastName, std::string phone) : + id{id}, firstName{move(firstName)}, lastName{move(lastName)}, phone{move(phone)} {} +#endif }; struct Customer { @@ -33,6 +45,27 @@ struct Customer { std::unique_ptr fax; std::string email; int supportRepId = 0; + +#ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED + Customer() {} + Customer(int id, + std::string firstName, + std::string lastName, + std::string company, + std::string address, + std::string city, + std::string state, + std::string country, + std::string postalCode, + std::string phone, + std::unique_ptr fax, + std::string email, + int supportRepId) : + id{id}, + firstName{move(firstName)}, lastName{move(lastName)}, company{move(company)}, address{move(address)}, + city{move(city)}, state{move(state)}, country{move(country)}, postalCode{move(postalCode)}, phone{move(phone)}, + fax{move(fax)}, email{move(email)}, supportRepId{supportRepId} {} +#endif }; int main(int, char** argv) { diff --git a/examples/custom_aliases.cpp b/examples/custom_aliases.cpp index b7ac51e62..47daf1553 100644 --- a/examples/custom_aliases.cpp +++ b/examples/custom_aliases.cpp @@ -17,12 +17,23 @@ struct Employee { int age = 0; std::string address; float salary = 0; + +#ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED + Employee() {} + Employee(int id, std::string name, int age, std::string address, float salary) : + id{id}, name{move(name)}, age{age}, address{move(address)}, salary{salary} {} +#endif }; struct Department { int id = 0; std::string dept; int empId = 0; + +#ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED + Department() {} + Department(int id, std::string dept, int empId) : id{id}, dept{move(dept)}, empId{empId} {} +#endif }; using namespace sqlite_orm; diff --git a/examples/except_intersection.cpp b/examples/except_intersection.cpp index aae4a2991..03a36d151 100644 --- a/examples/except_intersection.cpp +++ b/examples/except_intersection.cpp @@ -11,6 +11,11 @@ using std::endl; struct DeptMaster { int deptId = 0; std::string deptName; + +#ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED + DeptMaster() = default; + DeptMaster(int deptId, std::string deptName) : deptId{deptId}, deptName{move(deptName)} {} +#endif }; struct EmpMaster { @@ -19,6 +24,17 @@ struct EmpMaster { std::string lastName; long salary; decltype(DeptMaster::deptId) deptId; + +#ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED + EmpMaster() = default; + EmpMaster(int empId, + std::string firstName, + std::string lastName, + long salary, + decltype(DeptMaster::deptId) deptId) : + empId{empId}, + firstName{move(firstName)}, lastName{move(lastName)}, salary{salary}, deptId{deptId} {} +#endif }; int main() { diff --git a/examples/generated_column.cpp b/examples/generated_column.cpp index 129792ceb..e8e8cfb95 100644 --- a/examples/generated_column.cpp +++ b/examples/generated_column.cpp @@ -18,6 +18,12 @@ int main() { int quantity = 0; float price = 0; float totalValue = 0; + +#ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED + Product() {} + Product(int id, std::string name, int quantity, float price, float totalValue = 0.f) : + id{id}, name{move(name)}, quantity{quantity}, price{price}, totalValue{totalValue} {} +#endif }; auto storage = make_storage({}, make_table("products", diff --git a/examples/prepared_statement.cpp b/examples/prepared_statement.cpp index 0ac8c7648..6a43a883f 100644 --- a/examples/prepared_statement.cpp +++ b/examples/prepared_statement.cpp @@ -18,18 +18,36 @@ struct Doctor { int doctor_id = 0; std::string doctor_name; std::string degree; + +#ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED + Doctor() = default; + Doctor(int doctor_id, std::string doctor_name, std::string degree) : + doctor_id{doctor_id}, doctor_name{move(doctor_name)}, degree{move(degree)} {} +#endif }; struct Speciality { int spl_id = 0; std::string spl_descrip; int doctor_id = 0; + +#ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED + Speciality() = default; + Speciality(int spl_id, std::string spl_descrip, int doctor_id) : + spl_id{spl_id}, spl_descrip{move(spl_descrip)}, doctor_id{doctor_id} {} +#endif }; struct Visit { int doctor_id = 0; std::string patient_name; std::string vdate; + +#ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED + Visit() = default; + Visit(int doctor_id, std::string patient_name, std::string vdate) : + doctor_id{doctor_id}, patient_name{move(patient_name)}, vdate{move(vdate)} {} +#endif }; int main() { diff --git a/examples/triggers.cpp b/examples/triggers.cpp index 585b57bf9..0a8dc6726 100644 --- a/examples/triggers.cpp +++ b/examples/triggers.cpp @@ -16,6 +16,12 @@ struct Lead { std::string lastName; std::string email; std::string phone; + +#ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED + Lead() = default; + Lead(int id, std::string firstName, std::string lastName, std::string email, std::string phone) : + id{id}, firstName{move(firstName)}, lastName{move(lastName)}, email{move(email)}, phone{move(phone)} {} +#endif }; struct LeadLog { diff --git a/examples/user_defined_functions.cpp b/examples/user_defined_functions.cpp index d9bce0678..34bb30c33 100644 --- a/examples/user_defined_functions.cpp +++ b/examples/user_defined_functions.cpp @@ -112,6 +112,11 @@ int main() { int a = 0; int b = 0; int c = 0; + +#ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED + Table() = default; + Table(int a, int b, int c) : a{a}, b{b}, c{c} {} +#endif }; auto storage = make_storage( diff --git a/tests/statement_serializer_tests/statements/insert_replace.cpp b/tests/statement_serializer_tests/statements/insert_replace.cpp index c5eb90b30..b13e7e08a 100644 --- a/tests/statement_serializer_tests/statements/insert_replace.cpp +++ b/tests/statement_serializer_tests/statements/insert_replace.cpp @@ -14,7 +14,7 @@ TEST_CASE("statement_serializer insert/replace") { int id = 0; std::string name; -#if !defined(SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED) || !defined(SQLITE_ORM_AGGREGATE_BASES_SUPPORTED) +#ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED User() = default; User(int id, std::string name) : id{id}, name{move(name)} {} #endif