Defines a primary key with the specified columns.
Columns of the primary key must not be nullable.
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
The following code demonstrates the generated definition of the primary key in the table type:
class TableType {
public:
class IDType;
class NameType;
public:
PrimaryKeyType(const PrimaryKeyType&) = delete;
PrimaryKeyType& operator=(const PrimaryKeyType&) = delete;
PrimaryKeyType(PrimaryKeyType&&) = delete;
PrimaryKeyType& operator=(PrimaryKeyType&&) = delete;
constexpr auto operator=(const ValueType&) const noexcept;
constexpr auto Asc() const noexcept;
constexpr auto Desc() const noexcept;
friend constexpr auto operator==(const PrimaryKeyType&, const ValueType&) const noexcept;
friend constexpr auto operator==(const PrimaryKeyType&, sqt::Placeholder) const noexcept;
friend constexpr auto operator==(const ValueType&, const PrimaryKeyType&) const noexcept;
friend constexpr auto operator==(sqt::Placeholder, const PrimaryKeyType&) const noexcept;
};
PrimaryKeyType PrimaryKey;
};
Represents a primary key for a table, which is a composite of one or more columns.
Definition primary_key.h:29