mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-07 21:50:34 -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:
@@ -42,7 +42,7 @@ int Result(int, char* [])
|
||||
static_assert(not sqlpp::null_is_trivial_value_t<decltype(t.alpha)>::value, "t.alpha does not say null_is_trivial");
|
||||
|
||||
// Using a non-enforcing db
|
||||
for (const auto& row : db(select(all_of(t), t.beta.like("")).from(t).where(true)))
|
||||
for (const auto& row : db(select(all_of(t), t.beta.like("")).from(t).unconditionally()))
|
||||
{
|
||||
static_assert(sqlpp::can_be_null_t<decltype(row.alpha)>::value, "row.alpha can be null");
|
||||
static_assert(sqlpp::null_is_trivial_value_t<decltype(row.alpha)>::value, "row.alpha interprets null_is_trivial");
|
||||
@@ -64,14 +64,14 @@ int Result(int, char* [])
|
||||
}
|
||||
|
||||
sqlpp::select((t.alpha + 1).as(t.alpha)).flags(sqlpp::all).from(t);
|
||||
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(sqlpp::can_be_null_t<decltype(row.alpha)>::value, "row.alpha can be null");
|
||||
static_assert(sqlpp::null_is_trivial_value_t<decltype(row.alpha)>::value, "row.alpha interprets null_is_trivial");
|
||||
}
|
||||
|
||||
// Using a non-enforcing db
|
||||
for (const auto& row : edb(select(all_of(t)).from(t).where(true)))
|
||||
for (const auto& row : edb(select(all_of(t)).from(t).unconditionally()))
|
||||
{
|
||||
static_assert(sqlpp::can_be_null_t<decltype(row.alpha)>::value, "row.alpha can be null");
|
||||
static_assert(not sqlpp::null_is_trivial_value_t<decltype(row.alpha)>::value,
|
||||
@@ -79,7 +79,7 @@ int Result(int, char* [])
|
||||
}
|
||||
|
||||
sqlpp::select((t.alpha + 1).as(t.alpha)).flags(sqlpp::all).from(t);
|
||||
for (const auto& row : edb(select(all_of(t)).from(t).where(true)))
|
||||
for (const auto& row : edb(select(all_of(t)).from(t).unconditionally()))
|
||||
{
|
||||
static_assert(sqlpp::can_be_null_t<decltype(row.alpha)>::value, "row.alpha can be null");
|
||||
static_assert(not sqlpp::null_is_trivial_value_t<decltype(row.alpha)>::value,
|
||||
|
||||
Reference in New Issue
Block a user