13template <auto ColumnPtr>
22 return "UNIQUE (" + std::string(column_type::name) +
")";
28template <
auto... ColumnPtrs>
37 std::string result =
"UNIQUE (";
38 result += get_column_names();
45 std::string get_column_names()
const {
48 (append_column_name<ColumnPtrs>(names, names.empty() ?
"" :
", "), ...);
53 template <auto ColumnPtr>
54 void append_column_name(std::string& names,
const std::string& separator)
const {
55 using column_type =
typename member_pointer_type<
decltype(ColumnPtr)>::type;
56 names += separator + std::string(column_type::name);
Represents a composite UNIQUE constraint on multiple columns.
composite_unique_constraint()=default
Default constructor.
std::string sql_definition() const
Get SQL definition for the composite UNIQUE constraint.
Represents a UNIQUE constraint on a table.
std::string sql_definition() const
Get SQL definition for the UNIQUE constraint.
Helper to extract the member type from a member pointer.