16template <fixed_string Condition, fixed_string Name =
"">
25 if constexpr (!Name.empty()) {
26 result =
"CONSTRAINT " + std::string(std::string_view(Name)) +
" ";
30 result +=
"CHECK (" + std::string(std::string_view(Condition)) +
")";
36 constexpr std::string_view
condition()
const {
return std::string_view(Condition); }
40 constexpr std::string_view
name()
const {
return std::string_view(Name); }
57 if constexpr (!Name.empty()) {
58 result =
"CONSTRAINT " + std::string(std::string_view(Name)) +
" ";
65 std::string condition_str = std::string(std::string_view(Condition));
66 result +=
"CHECK (" + condition_str +
")";
73 constexpr std::string_view
condition()
const {
return std::string_view(Condition); }
77 constexpr std::string_view
name()
const {
return std::string_view(Name); }
83 return column_type::name;
91template <fixed_
string Condition, fixed_
string Name>
99template <fixed_
string Condition>
108template <auto ColumnPtr, fixed_
string Condition>
118template <auto ColumnPtr, fixed_
string Condition, fixed_
string Name>
Check constraint explicitly associated with a column.
constexpr std::string_view name() const
Get the name as a string_view.
constexpr std::string sql_definition() const
Get SQL definition for the column-specific CHECK constraint.
std::string_view column_name() const
Get the associated column name.
constexpr std::string_view condition() const
Get the condition as a string_view.
Check constraint that accepts a condition string at compile time.
constexpr std::string sql_definition() const
Get SQL definition for the CHECK constraint.
constexpr std::string_view name() const
Get the name as a string_view.
constexpr std::string_view condition() const
Get the condition as a string_view.
constexpr auto table_check()
Helper function to create an unnamed check constraint at compile time.
constexpr auto named_check()
Helper function to create a named check constraint at compile time.
constexpr auto column_check()
Helper function to create a column-bound check constraint at compile time.
constexpr auto named_column_check()
Helper function to create a named column-bound check constraint at compile time.
Compile-time string type that can be used as template non-type parameter in C++20.
Helper to extract the member type from a member pointer.