您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

62 行
2.0 KiB

  1. #pragma once
  2. #include "../../helper/key_properties.h"
  3. namespace cpphibernate {
  4. namespace mariadb {
  5. /**
  6. * @brief Field that represents a primary key field.
  7. */
  8. template<typename T_field>
  9. struct field_primary_key_t
  10. : public field_value_t<T_field>
  11. {
  12. private:
  13. using base_type = field_value_t<T_field>;
  14. public:
  15. static constexpr decltype(auto) key_props =
  16. key_properties<typename decltype(+base_type::value_type)::type> { };
  17. public:
  18. /**
  19. * @brief Value constructor. Creates a mariadb field from the cpphibernate field.
  20. *
  21. * @param[in] p_owner Owner of the field.
  22. * @param[in] p_schema Cpphibernate schema the mariadb field belongs to.
  23. * @param[in] p_table Cpphibernate table the mariadb field belongs to.
  24. * @param[in] p_field Cpphibernate field to create mariadb field for.
  25. */
  26. template<
  27. typename T_schema,
  28. typename T_table>
  29. inline field_primary_key_t(
  30. const table_t& p_owner,
  31. const T_schema& p_schema,
  32. const T_table& p_table,
  33. const T_field& p_field);
  34. public:
  35. /**
  36. * @brief Check if the value that is represented by this field has the default value.
  37. *
  38. * @param[in] context Data context to receive the value of the assigned dataset.
  39. *
  40. * @retval true If the dataset in the context is the default value for this field.
  41. * @retval false If the dataset in the context is not the default value for this field.
  42. */
  43. bool is_default(const data_context& context) const override;
  44. /**
  45. * @brief Create a new value that is represented by this field.
  46. *
  47. * @param[in] connection Connection to use to create the value.
  48. *
  49. * @return New created value for this field.
  50. */
  51. std::string generate_value(::cppmariadb::connection& connection) const override;
  52. };
  53. } }