From 5b2b175b21ea64206aaf1295768c8b38f0ec57ab Mon Sep 17 00:00:00 2001 From: rbock Date: Wed, 28 Aug 2019 09:42:48 +0200 Subject: [PATCH] Remove aggregate attribute from `trim()` --- include/sqlpp11/trim.h | 6 ++---- tests/Select.cpp | 32 ++++++++++++++++---------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/include/sqlpp11/trim.h b/include/sqlpp11/trim.h index 32c7a1e5..43b009a7 100644 --- a/include/sqlpp11/trim.h +++ b/include/sqlpp11/trim.h @@ -57,12 +57,11 @@ namespace sqlpp }; template - struct trim_t : public expression_operators, text>, - public alias_operators> + struct trim_t : public expression_operators, text>, public alias_operators> { using _traits = make_traits; - using _nodes = detail::type_vector; + using _nodes = detail::type_vector; using _can_be_null = can_be_null_t; using _is_aggregate_expression = std::false_type; @@ -94,7 +93,6 @@ namespace sqlpp context << ")"; return context; } - }; template diff --git a/tests/Select.cpp b/tests/Select.cpp index 90f25f70..0860479e 100644 --- a/tests/Select.cpp +++ b/tests/Select.cpp @@ -61,7 +61,7 @@ void print_row(Row const& row) std::cout << a << ", " << b << std::endl; } -int Select(int, char* []) +int Select(int, char*[]) { MockDb db = {}; MockDb::_serializer_context_t printer = {}; @@ -107,11 +107,12 @@ int Select(int, char* []) std::cout << a << ", " << b << ", " << g << std::endl; } - for (const auto& row : db(select(all_of(t).as(t), t.gamma).from(t).where(t.alpha > 7).for_update())) + for (const auto& row : + db(select(all_of(t), t.gamma.as(t)).from(t).where(t.alpha > 7 and trim(t.beta) == "test").for_update())) { - int64_t a = row.tabBar.alpha; - const std::string b = row.tabBar.beta; - const bool g = row.gamma; + int64_t a = row.alpha; + const std::string b = row.beta; + const bool g = row.tabBar; std::cout << a << ", " << b << ", " << g << std::endl; } @@ -208,20 +209,19 @@ int Select(int, char* []) } { - auto transaction = start_transaction(db, sqlpp::isolation_level::read_committed); - if (db._mock_data._last_isolation_level != sqlpp::isolation_level::read_committed) - { - std::cout << "Error: transaction isolation level does not match expected level" << std::endl; - } - + auto transaction = start_transaction(db, sqlpp::isolation_level::read_committed); + if (db._mock_data._last_isolation_level != sqlpp::isolation_level::read_committed) + { + std::cout << "Error: transaction isolation level does not match expected level" << std::endl; + } } db.set_default_isolation_level(sqlpp::isolation_level::read_uncommitted); { - auto transaction = start_transaction(db); - if (db._mock_data._last_isolation_level != sqlpp::isolation_level::read_uncommitted) - { - std::cout << "Error: transaction isolation level does not match default level" << std::endl; - } + auto transaction = start_transaction(db); + if (db._mock_data._last_isolation_level != sqlpp::isolation_level::read_uncommitted) + { + std::cout << "Error: transaction isolation level does not match default level" << std::endl; + } } return 0;