mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
Fix missing space for operator-
This commit is contained in:
parent
268c176d8a
commit
bb77cc1459
@ -98,7 +98,17 @@ namespace sqlpp
|
||||
struct minus
|
||||
{
|
||||
using _traits = make_traits<ValueType>;
|
||||
static constexpr const char* _name = "-";
|
||||
// The trailing space is necessary to prevent
|
||||
// ```
|
||||
// t.id - -1
|
||||
// ```
|
||||
// from turning into
|
||||
// ```
|
||||
// tab_sample.id--1
|
||||
// ```
|
||||
// (-- starts a comment in SQL)
|
||||
// See https://github.com/rbock/sqlpp11/issues/294
|
||||
static constexpr const char* _name = " - ";
|
||||
};
|
||||
|
||||
template <typename ValueType>
|
||||
|
@ -31,18 +31,18 @@
|
||||
|
||||
SQLPP_ALIAS_PROVIDER(cheese)
|
||||
|
||||
int As(int, char* [])
|
||||
int As(int, char*[])
|
||||
{
|
||||
const auto foo = test::TabFoo{};
|
||||
const auto bar = test::TabBar{};
|
||||
|
||||
compare(__LINE__, foo.omega.as(cheese), "tab_foo.omega AS cheese");
|
||||
compare(__LINE__, (foo.omega + 17).as(cheese), "(tab_foo.omega+17) AS cheese");
|
||||
compare(__LINE__, (foo.omega - 17).as(cheese), "(tab_foo.omega-17) AS cheese");
|
||||
compare(__LINE__, (foo.omega - uint32_t(17)).as(cheese), "(tab_foo.omega-17) AS cheese");
|
||||
compare(__LINE__, (foo.omega - bar.alpha).as(cheese), "(tab_foo.omega-tab_bar.alpha) AS cheese");
|
||||
compare(__LINE__, (count(foo.omega) - bar.alpha).as(cheese), "(COUNT(tab_foo.omega)-tab_bar.alpha) AS cheese");
|
||||
compare(__LINE__, (count(foo.omega) - uint32_t(17)).as(cheese), "(COUNT(tab_foo.omega)-17) AS cheese");
|
||||
compare(__LINE__, (foo.omega - 17).as(cheese), "(tab_foo.omega - 17) AS cheese");
|
||||
compare(__LINE__, (foo.omega - uint32_t(17)).as(cheese), "(tab_foo.omega - 17) AS cheese");
|
||||
compare(__LINE__, (foo.omega - bar.alpha).as(cheese), "(tab_foo.omega - tab_bar.alpha) AS cheese");
|
||||
compare(__LINE__, (count(foo.omega) - bar.alpha).as(cheese), "(COUNT(tab_foo.omega) - tab_bar.alpha) AS cheese");
|
||||
compare(__LINE__, (count(foo.omega) - uint32_t(17)).as(cheese), "(COUNT(tab_foo.omega) - 17) AS cheese");
|
||||
|
||||
// Auto alias
|
||||
compare(__LINE__, select(max(bar.alpha)), "SELECT MAX(tab_bar.alpha) AS max_");
|
||||
|
@ -42,9 +42,9 @@ namespace
|
||||
MockDb::_serializer_context_t printer = {};
|
||||
return serialize(sqlpp::value(false), printer).str();
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int Where(int, char* [])
|
||||
int Where(int, char*[])
|
||||
{
|
||||
const auto foo = test::TabFoo{};
|
||||
const auto bar = test::TabBar{};
|
||||
@ -53,6 +53,8 @@ int Where(int, char* [])
|
||||
compare(__LINE__, select(foo.omega).from(foo).unconditionally(), "SELECT tab_foo.omega FROM tab_foo");
|
||||
compare(__LINE__, remove_from(foo).unconditionally(), "DELETE FROM tab_foo");
|
||||
compare(__LINE__, update(foo).set(foo.omega = 42).unconditionally(), "UPDATE tab_foo SET omega=42");
|
||||
compare(__LINE__, update(foo).set(foo.omega = foo.omega - -1).unconditionally(),
|
||||
"UPDATE tab_foo SET omega=(tab_foo.omega - -1)");
|
||||
compare(__LINE__, where(sqlpp::value(true)), " WHERE " + getTrue());
|
||||
|
||||
// Never
|
||||
|
Loading…
Reference in New Issue
Block a user