@@ -841,7 +841,7 @@ namespace sqlite_orm {
841841#include <system_error> // std::system_error
842842#include <ostream> // std::ostream
843843#include <string> // std::string
844- #include <tuple> // std::tuple, std::make_tuple
844+ #include <tuple> // std::tuple
845845#include <type_traits> // std::is_base_of, std::false_type, std::true_type
846846
847847// #include "functional/cxx_universal.h"
@@ -2016,7 +2016,7 @@ namespace sqlite_orm {
20162016
20172017 template<class... Rs>
20182018 foreign_key_t<std::tuple<Cs...>, std::tuple<Rs...>> references(Rs... refs) {
2019- return {std::move(this->columns), std::make_tuple(std:: forward<Rs>(refs)...) };
2019+ return {std::move(this->columns), { std::forward<Rs>(refs)...} };
20202020 }
20212021 };
20222022#endif
@@ -2136,17 +2136,16 @@ namespace sqlite_orm {
21362136 };
21372137
21382138 template<class T>
2139- using is_constraint = mpl::invoke_t<mpl::disjunction<check_if<is_primary_key>,
2140- check_if<is_foreign_key>,
2141- check_if_is_type<null_t>,
2142- check_if_is_type<not_null_t>,
2143- check_if_is_type<unindexed_t>,
2144- check_if_is_template<unique_t>,
2145- check_if_is_template<default_t>,
2146- check_if_is_template<check_t>,
2147- check_if_is_type<collate_constraint_t>,
2148- check_if<is_generated_always>>,
2149- T>;
2139+ using is_column_constraint = mpl::invoke_t<mpl::disjunction<check_if<is_primary_key>,
2140+ check_if_is_type<null_t>,
2141+ check_if_is_type<not_null_t>,
2142+ check_if_is_template<unique_t>,
2143+ check_if_is_template<default_t>,
2144+ check_if_is_template<check_t>,
2145+ check_if_is_type<collate_constraint_t>,
2146+ check_if<is_generated_always>,
2147+ check_if_is_type<unindexed_t>>,
2148+ T>;
21502149 }
21512150
21522151#if SQLITE_VERSION_NUMBER >= 3031000
@@ -2160,32 +2159,35 @@ namespace sqlite_orm {
21602159 return {std::move(expression), false, internal::basic_generated_always::storage_type::not_specified};
21612160 }
21622161#endif
2163- #if SQLITE_VERSION_NUMBER >= 3006019
21642162
2163+ #if SQLITE_VERSION_NUMBER >= 3006019
21652164 /**
21662165 * FOREIGN KEY constraint construction function that takes member pointer as argument
21672166 * Available in SQLite 3.6.19 or higher
21682167 */
21692168 template<class... Cs>
21702169 internal::foreign_key_intermediate_t<Cs...> foreign_key(Cs... columns) {
2171- return {std::make_tuple(std:: forward<Cs>(columns)...) };
2170+ return {{ std::forward<Cs>(columns)...} };
21722171 }
21732172#endif
21742173
21752174 /**
2176- * UNIQUE constraint builder function.
2175+ * UNIQUE table constraint builder function.
21772176 */
21782177 template<class... Args>
21792178 internal::unique_t<Args...> unique(Args... args) {
21802179 return {{std::forward<Args>(args)...}};
21812180 }
21822181
2182+ /**
2183+ * UNIQUE column constraint builder function.
2184+ */
21832185 inline internal::unique_t<> unique() {
21842186 return {{}};
21852187 }
21862188
21872189 /**
2188- * UNINDEXED constraint builder function. Used in FTS virtual tables.
2190+ * UNINDEXED column constraint builder function. Used in FTS virtual tables.
21892191 *
21902192 * https://www.sqlite.org/fts5.html#the_unindexed_column_option
21912193 */
@@ -2194,7 +2196,7 @@ namespace sqlite_orm {
21942196 }
21952197
21962198 /**
2197- * prefix=N constraint builder function. Used in FTS virtual tables.
2199+ * prefix=N table constraint builder function. Used in FTS virtual tables.
21982200 *
21992201 * https://www.sqlite.org/fts5.html#prefix_indexes
22002202 */
@@ -2203,11 +2205,17 @@ namespace sqlite_orm {
22032205 return {std::move(value)};
22042206 }
22052207
2208+ /**
2209+ * PRIMARY KEY table constraint builder function.
2210+ */
22062211 template<class... Cs>
22072212 internal::primary_key_t<Cs...> primary_key(Cs... cs) {
2208- return {std::make_tuple(std:: forward<Cs>(cs)...) };
2213+ return {{ std::forward<Cs>(cs)...} };
22092214 }
22102215
2216+ /**
2217+ * PRIMARY KEY column constraint builder function.
2218+ */
22112219 inline internal::primary_key_t<> primary_key() {
22122220 return {{}};
22132221 }
@@ -2985,7 +2993,7 @@ namespace sqlite_orm {
29852993 template<class M, class... Op, internal::satisfies<std::is_member_object_pointer, M> = true>
29862994 internal::column_t<M, internal::empty_setter, Op...>
29872995 make_column(std::string name, M memberPointer, Op... constraints) {
2988- static_assert(polyfill::conjunction_v<internal::is_constraint <Op>...>, "Incorrect constraints pack");
2996+ static_assert(polyfill::conjunction_v<internal::is_column_constraint <Op>...>, "Incorrect constraints pack");
29892997
29902998 // attention: do not use `std::make_tuple()` for constructing the tuple member `[[no_unique_address]] column_constraints::constraints`,
29912999 // as this will lead to UB with Clang on MinGW!
@@ -3004,7 +3012,7 @@ namespace sqlite_orm {
30043012 internal::column_t<G, S, Op...> make_column(std::string name, S setter, G getter, Op... constraints) {
30053013 static_assert(std::is_same<internal::setter_field_type_t<S>, internal::getter_field_type_t<G>>::value,
30063014 "Getter and setter must get and set same data type");
3007- static_assert(polyfill::conjunction_v<internal::is_constraint <Op>...>, "Incorrect constraints pack");
3015+ static_assert(polyfill::conjunction_v<internal::is_column_constraint <Op>...>, "Incorrect constraints pack");
30083016
30093017 // attention: do not use `std::make_tuple()` for constructing the tuple member `[[no_unique_address]] column_constraints::constraints`,
30103018 // as this will lead to UB with Clang on MinGW!
@@ -3023,7 +3031,7 @@ namespace sqlite_orm {
30233031 internal::column_t<G, S, Op...> make_column(std::string name, G getter, S setter, Op... constraints) {
30243032 static_assert(std::is_same<internal::setter_field_type_t<S>, internal::getter_field_type_t<G>>::value,
30253033 "Getter and setter must get and set same data type");
3026- static_assert(polyfill::conjunction_v<internal::is_constraint <Op>...>, "Incorrect constraints pack");
3034+ static_assert(polyfill::conjunction_v<internal::is_column_constraint <Op>...>, "Incorrect constraints pack");
30273035
30283036 // attention: do not use `std::make_tuple()` for constructing the tuple member `[[no_unique_address]] column_constraints::constraints`,
30293037 // as this will lead to UB with Clang on MinGW!
@@ -11260,6 +11268,16 @@ namespace sqlite_orm {
1126011268
1126111269 namespace internal {
1126211270
11271+ template<class T>
11272+ using is_table_element_or_constraint = mpl::invoke_t<mpl::disjunction<check_if<is_column>,
11273+ check_if<is_primary_key>,
11274+ check_if<is_foreign_key>,
11275+ check_if_is_template<index_t>,
11276+ check_if_is_template<unique_t>,
11277+ check_if_is_template<check_t>,
11278+ check_if_is_template<prefix_t>>,
11279+ T>;
11280+
1126311281#ifdef SQLITE_ORM_WITH_CTE
1126411282 /**
1126511283 * A subselect mapper's CTE moniker, void otherwise.
@@ -11634,11 +11652,17 @@ namespace sqlite_orm {
1163411652
1163511653 template<class... Cs, class T = typename std::tuple_element_t<0, std::tuple<Cs...>>::object_type>
1163611654 internal::using_fts5_t<T, Cs...> using_fts5(Cs... columns) {
11655+ static_assert(polyfill::conjunction_v<internal::is_table_element_or_constraint<Cs>...>,
11656+ "Incorrect table elements or constraints");
11657+
1163711658 SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(return {std::make_tuple(std::forward<Cs>(columns)...)});
1163811659 }
1163911660
1164011661 template<class T, class... Cs>
1164111662 internal::using_fts5_t<T, Cs...> using_fts5(Cs... columns) {
11663+ static_assert(polyfill::conjunction_v<internal::is_table_element_or_constraint<Cs>...>,
11664+ "Incorrect table elements or constraints");
11665+
1164211666 SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(return {std::make_tuple(std::forward<Cs>(columns)...)});
1164311667 }
1164411668
@@ -11649,6 +11673,9 @@ namespace sqlite_orm {
1164911673 */
1165011674 template<class... Cs, class T = typename std::tuple_element_t<0, std::tuple<Cs...>>::object_type>
1165111675 internal::table_t<T, false, Cs...> make_table(std::string name, Cs... args) {
11676+ static_assert(polyfill::conjunction_v<internal::is_table_element_or_constraint<Cs>...>,
11677+ "Incorrect table elements or constraints");
11678+
1165211679 SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(
1165311680 return {std::move(name), std::make_tuple<Cs...>(std::forward<Cs>(args)...)});
1165411681 }
@@ -11660,6 +11687,9 @@ namespace sqlite_orm {
1166011687 */
1166111688 template<class T, class... Cs>
1166211689 internal::table_t<T, false, Cs...> make_table(std::string name, Cs... args) {
11690+ static_assert(polyfill::conjunction_v<internal::is_table_element_or_constraint<Cs>...>,
11691+ "Incorrect table elements or constraints");
11692+
1166311693 SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(
1166411694 return {std::move(name), std::make_tuple<Cs...>(std::forward<Cs>(args)...)});
1166511695 }
0 commit comments