Constrains a type to be a querier type, which corresponds to a SQL statement that can be executed.
Requirements
- The type must have a static constant ParameterIndex of type std::size_t, with a value greater than 0.
- The type must have a static constant ParameterCount of type std::size_t.
- The type must have a static method BuildSQL() with the following signature:
static std::string_view BuildSQL();
- The type must have a static method BuildPlaceholderBinders() with the following signature:
static auto BuildPlaceholderBinders() noexcept;
The return type must satisfy the sqt::BinderTupleType concept.
- The type must have a member function BindInlineParameters() with the following signature:
Wrapper class for SQLite statement.
Definition statement.h:21
A querier is an encapsulation for a SQL statement. Each querier instance corresponds to a well-formed SQL statement that can be executed. There are four types of queriers:
- Inserter, which corresponds to an INSERT SQL statement.
- Updater, which corresponds to an UPDATE SQL statement.
- Deleter, which corresponds to a DELETE SQL statement.
- Selecter, which corresponds to a SELECT SQL statement, constrained by the sqt::SelecterType concept.
The Make*() methods in sqt::DataContext<> are used to create queriers, referred to as primary queriers, which contain the core components of a SQL statement. For instance:
struct MyEntity {
int id{};
std::string name;
};
static constexpr auto MakeSelecter() noexcept
Creates a selecter for retrieving entities from the database table.
Definition data_context.h:520
The above code creates a primary selecter corresponds to the following SQL statement:
SELECT id, name FROM MyEntity;
Querier decorators add additional clauses to the SQL statement. They are created by decorative methods of queriers (either primary queriers or querier decorators). For instance:
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
The above code creates a selecter decorator in chain fashion. The decorator corresponds to the following SQL statement:
SELECT id, name FROM MyEntity WHERE name <> "Unknown" ORDER BY id DESC;
- See also
- sqt::BinderTupleType
-
sqt::DataContext<>
-
sqt::SelecterType