mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-18 02:59:52 -06:00
Prevent unconditional joins, and naked bool in where() or boolean expressions
- `.from(t1, t2)` produces an unconditional join if you forget to add a condition in the .where() sqlpp11 therefore now deprecates unconditional joins. - more often than not, writing something like `where(name == "doe")`, you meant to write `where(t.name == "doe")`. It is hard to find bugs when the former expression compiles because you happen to have a variable `name` in the current scope as well. sqlpp11 therefore now deprecates `.where(bool)` and disallows raw bool values boolean expression like `something and bool` wrap bools in sqlpp::value(), if you REALLY want a bool value here
This commit is contained in:
@@ -197,7 +197,7 @@ int Function(int, char* [])
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
|
||||
if (false and db(select(exists(select(t.alpha).from(t).where(true)))).front().exists)
|
||||
if (false and db(select(exists(select(t.alpha).from(t).unconditionally()))).front().exists)
|
||||
{ /* do something */
|
||||
}
|
||||
}
|
||||
@@ -286,7 +286,7 @@ int Function(int, char* [])
|
||||
static_assert(sqlpp::is_integral_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<TT>::value, "type requirement");
|
||||
|
||||
if (false and db(select(count(t.alpha)).from(t).where(true)).front().count > 0)
|
||||
if (false and db(select(count(t.alpha)).from(t).unconditionally()).front().count > 0)
|
||||
{ /* do something */
|
||||
}
|
||||
}
|
||||
@@ -444,7 +444,7 @@ int Function(int, char* [])
|
||||
static_assert(std::is_same<decltype(sqlpp::tvin("test")), sqlpp::tvin_arg_t<sqlpp::text_operand>>::value,
|
||||
"text values are accepted and wrapped");
|
||||
|
||||
for (const auto& row : db(select(all_of(t)).from(t).where(true)))
|
||||
for (const auto& row : db(select(all_of(t)).from(t).unconditionally()))
|
||||
{
|
||||
static_assert(std::is_same<decltype(sqlpp::tvin(row.alpha)),
|
||||
sqlpp::tvin_arg_t<typename std::remove_const<decltype(row.alpha)>::type>>::value,
|
||||
|
||||
Reference in New Issue
Block a user