diff --git a/include/sqlgen/select_from.hpp b/include/sqlgen/select_from.hpp index 1a26f21b..996508a9 100644 --- a/include/sqlgen/select_from.hpp +++ b/include/sqlgen/select_from.hpp @@ -133,6 +133,17 @@ struct SelectFrom { const SelectFrom& _s, const transpilation::Join& _join) { + static_assert(std::is_same_v, + "You cannot call where(...) before a join."); + static_assert(std::is_same_v, + "You cannot call group_by(...) before a join."); + static_assert(std::is_same_v, + "You cannot call order_by(...) before a join."); + static_assert(std::is_same_v, + "You cannot call limit(...) before a join."); + static_assert(std::is_same_v, + "You cannot call to<...> before a join."); + if constexpr (std::is_same_v) { using NewJoinsType = rfl::Tuple< transpilation::Join>; @@ -161,6 +172,8 @@ struct SelectFrom { static_assert(std::is_same_v, "You cannot call where(...) twice (but you can apply more " "than one condition by combining them with && or ||)."); + static_assert(std::is_same_v, + "You cannot call group_by(...) before where(...)."); static_assert(std::is_same_v, "You cannot call order_by(...) before where(...)."); static_assert(std::is_same_v, diff --git a/include/sqlgen/transpilation/columns_t.hpp b/include/sqlgen/transpilation/columns_t.hpp index c06eebd8..092c65e2 100644 --- a/include/sqlgen/transpilation/columns_t.hpp +++ b/include/sqlgen/transpilation/columns_t.hpp @@ -21,7 +21,8 @@ struct Columns { template auto make_columns() { - static_assert(all_columns_exist(), "All columns must exist."); + static_assert(all_columns_exist(), + "At least one column referenced in your query does not exist."); return Columns{}; } diff --git a/include/sqlgen/transpilation/table_tuple_t.hpp b/include/sqlgen/transpilation/table_tuple_t.hpp index 46d5464c..d5992c06 100644 --- a/include/sqlgen/transpilation/table_tuple_t.hpp +++ b/include/sqlgen/transpilation/table_tuple_t.hpp @@ -25,6 +25,9 @@ struct TableTupleType> { std::pair, AliasType>, std::pair, typename JoinTypes::Alias>...>; + static_assert( + !rfl::define_literal_t::has_duplicates(), + "Your SELECT FROM query cannot contain duplicate aliases."); }; template diff --git a/include/sqlgen/transpilation/to_sets.hpp b/include/sqlgen/transpilation/to_sets.hpp index f05fb73e..3a071f84 100644 --- a/include/sqlgen/transpilation/to_sets.hpp +++ b/include/sqlgen/transpilation/to_sets.hpp @@ -27,8 +27,9 @@ struct ToSet; template struct ToSet, ToType>> { - static_assert(all_columns_exist>(), - "All columns must exist."); + static_assert( + all_columns_exist>(), + "At least one column referenced in your SET query does not exist."); static_assert(std::is_convertible_v>, underlying_t>>, "Must be convertible."); @@ -44,14 +45,17 @@ struct ToSet, ToType>> { template struct ToSet, transpilation::Col<_name2>>> { - static_assert(all_columns_exist>(), - "All columns must exist."); - static_assert(all_columns_exist>(), - "All columns must exist."); + static_assert( + all_columns_exist>(), + "At least one column referenced in your SET query does not exist."); + static_assert( + all_columns_exist>(), + "At least one column referenced in your SET query does not exist."); static_assert( std::is_convertible_v>, underlying_t>>, - "Must be convertible."); + "A column referenced in your SET query is not convertible to the column " + "it is being assigned to."); dynamic::Update::Set operator()(const auto& _set) const { return dynamic::Update::Set{ diff --git a/include/sqlgen/transpilation/underlying_t.hpp b/include/sqlgen/transpilation/underlying_t.hpp index 910a9bb4..9c26de8a 100644 --- a/include/sqlgen/transpilation/underlying_t.hpp +++ b/include/sqlgen/transpilation/underlying_t.hpp @@ -34,7 +34,7 @@ template struct Underlying> { static_assert(all_columns_exist>(), - "All columns must exist."); + "At least one column referenced in your query does not exist."); using Type = remove_reflection_t< rfl::field_type_t<_name, get_table_t, TableTupleType>>>; };