|
- #pragma once
-
- #include "../../helper/key_properties.h"
-
- namespace cpphibernate {
- namespace mariadb {
-
- /**
- * @brief Field that represents a primary key field.
- */
- template<typename T_field>
- struct field_primary_key_t
- : public field_value_t<T_field>
- {
- private:
- using base_type = field_value_t<T_field>;
-
- public:
- static constexpr decltype(auto) key_props =
- key_properties<typename decltype(+base_type::value_type)::type> { };
-
- public:
- /**
- * @brief Value constructor. Creates a mariadb field from the cpphibernate field.
- *
- * @param[in] p_owner Owner of the field.
- * @param[in] p_schema Cpphibernate schema the mariadb field belongs to.
- * @param[in] p_table Cpphibernate table the mariadb field belongs to.
- * @param[in] p_field Cpphibernate field to create mariadb field for.
- */
- template<
- typename T_schema,
- typename T_table>
- inline field_primary_key_t(
- const table_t& p_owner,
- const T_schema& p_schema,
- const T_table& p_table,
- const T_field& p_field);
-
- public:
- /**
- * @brief Check if the value that is represented by this field has the default value.
- *
- * @param[in] context Data context to receive the value of the assigned dataset.
- *
- * @retval true If the dataset in the context is the default value for this field.
- * @retval false If the dataset in the context is not the default value for this field.
- */
- bool is_default(const data_context& context) const override;
-
- /**
- * @brief Create a new value that is represented by this field.
- *
- * @param[in] connection Connection to use to create the value.
- *
- * @return New created value for this field.
- */
- std::string generate_value(::cppmariadb::connection& connection) const override;
- };
-
- } }
|