0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-15 20:31:16 +08:00

Remove aggregate attribute from trim()

This commit is contained in:
rbock 2019-08-28 09:42:48 +02:00
parent 4f9f001fbd
commit 5b2b175b21
2 changed files with 18 additions and 20 deletions

View File

@ -57,12 +57,11 @@ namespace sqlpp
}; };
template <typename Flag, typename Expr> template <typename Flag, typename Expr>
struct trim_t : public expression_operators<trim_t<Flag, Expr>, text>, struct trim_t : public expression_operators<trim_t<Flag, Expr>, text>, public alias_operators<trim_t<Flag, Expr>>
public alias_operators<trim_t<Flag, Expr>>
{ {
using _traits = make_traits<text, tag::is_expression, tag::is_selectable>; using _traits = make_traits<text, tag::is_expression, tag::is_selectable>;
using _nodes = detail::type_vector<Expr, aggregate_function>; using _nodes = detail::type_vector<Expr>;
using _can_be_null = can_be_null_t<Expr>; using _can_be_null = can_be_null_t<Expr>;
using _is_aggregate_expression = std::false_type; using _is_aggregate_expression = std::false_type;
@ -94,7 +93,6 @@ namespace sqlpp
context << ")"; context << ")";
return context; return context;
} }
}; };
template <typename T> template <typename T>

View File

@ -61,7 +61,7 @@ void print_row(Row const& row)
std::cout << a << ", " << b << std::endl; std::cout << a << ", " << b << std::endl;
} }
int Select(int, char* []) int Select(int, char*[])
{ {
MockDb db = {}; MockDb db = {};
MockDb::_serializer_context_t printer = {}; MockDb::_serializer_context_t printer = {};
@ -107,11 +107,12 @@ int Select(int, char* [])
std::cout << a << ", " << b << ", " << g << std::endl; 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; int64_t a = row.alpha;
const std::string b = row.tabBar.beta; const std::string b = row.beta;
const bool g = row.gamma; const bool g = row.tabBar;
std::cout << a << ", " << b << ", " << g << std::endl; 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); auto transaction = start_transaction(db, sqlpp::isolation_level::read_committed);
if (db._mock_data._last_isolation_level != 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; std::cout << "Error: transaction isolation level does not match expected level" << std::endl;
} }
} }
db.set_default_isolation_level(sqlpp::isolation_level::read_uncommitted); db.set_default_isolation_level(sqlpp::isolation_level::read_uncommitted);
{ {
auto transaction = start_transaction(db); auto transaction = start_transaction(db);
if (db._mock_data._last_isolation_level != sqlpp::isolation_level::read_uncommitted) 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; std::cout << "Error: transaction isolation level does not match default level" << std::endl;
} }
} }
return 0; return 0;