Constrains a type to be a predicate type.
Requirements
Predicates are binary expressions that return a boolean, including comparison expressions and logical expressions. They are used in WHERE decorators of queriers to apply conditions to the SQL statement.
A predicate consists of an operator (specified by the sqt::PredicateOperator enum) and two operands (which must satisfy the sqt::PredicateTermType concept). Operands can also be a predicate, allowing to build a tree structure of predicates.
To create predicates, use the comparison operators (==, !=, <, <=, >, >=) on identifiers (including columns, primary keys and indexes), or logical operators (&&, ||) on other predicates. Consider the following entity type and its table definition:
struct MyEntity {
int id{};
std::string name;
};
#define SQT_COLUMN_FIELD(COLUMN_NAME, FIELD)
Defines a column that binds to the specified field of the entity type.
Definition table_definition.h:273
#define SQT_PRIMARY_KEY(...)
Defines a primary key with the specified columns.
Definition table_definition.h:608
#define SQT_TABLE_BEGIN(TABLE_NAME, ENTITY_TYPE)
Begins the definition of a table type for the specified entity type.
Definition table_definition.h:141
#define SQT_TABLE_END
Ends the definition of a table type.
Definition table_definition.h:854
#define SQT_INDEX(...)
Defines an index with auto-generated names based on the specified columns.
Definition table_definition.h:733
Examples of creating selecters with predicates:
);
);
);
);
static constexpr auto MakeSelecter() noexcept
Creates a selecter for retrieving entities from the database table.
Definition data_context.h:520
Represents a primary key for a table, which is a composite of one or more columns.
Definition primary_key.h:29
constexpr const auto & Table
A helper template to retrieve the singleton instance of the table type associated with an entity type...
Definition table_mapping.h:64
- See also
- sqt::ExpressionLike
-
sqt::PredicateOperator
-
sqt::PredicateTermType