88#include < type_traits>
99#include < utility>
1010
11- #include " ds_mysql/name_reflection .hpp"
11+ #include " ds_mysql/fixed_string .hpp"
1212#include " ds_mysql/sql_temporal.hpp"
1313#include " ds_mysql/varchar_field.hpp"
1414
@@ -19,10 +19,10 @@ namespace ds_mysql {
1919 */
2020struct column_field_tag {};
2121
22- // column_field<Tag , T> — the only user-facing form.
23- // Tag determines the SQL column name (via tag_to_column_name) ; T is the stored value type.
24- // using id = column_field<struct id_tag , uint32_t>;
25- template <typename Tag , typename T>
22+ // column_field<Name , T> — the only user-facing form.
23+ // Name is the SQL column name as a string literal ; T is the stored value type.
24+ // using id = column_field<"id" , uint32_t>;
25+ template <fixed_string Name , typename T>
2626struct column_field ;
2727
2828// ===================================================================
@@ -451,61 +451,36 @@ struct base<std::optional<sql_timestamp>> : column_field_tag {
451451} // namespace column_field_detail
452452
453453// ===================================================================
454- // column_field<Tag , T> — the only user-facing form
454+ // column_field<Name , T> — the only user-facing form
455455// ===================================================================
456456
457457/* *
458- * column_field<Tag , T> — tagged column descriptor.
458+ * column_field<Name , T> — named column descriptor.
459459 *
460- * Tag determines the SQL column name (stripped of any trailing "_tag" suffix) .
460+ * Name is the SQL column name embedded directly as a string literal .
461461 * T is the stored value type. All constructors and operators are inherited
462462 * from the internal base type.
463463 *
464- * using id = column_field<struct id_tag , uint32_t>;
465- * using ticker = column_field<struct ticker_tag , varchar_field<32>>;
466- * using sector = column_field<struct sector_tag , std::optional<varchar_field<64>>>;
464+ * using id = column_field<"id" , uint32_t>;
465+ * using ticker = column_field<"ticker" , varchar_field<32>>;
466+ * using sector = column_field<"sector" , std::optional<varchar_field<64>>>;
467467 *
468468 * id id_;
469469 * ticker ticker_;
470470 * sector sector_;
471471 *
472472 * SQL column names: "id", "ticker", "sector"
473473 */
474- template <typename Tag , typename T>
474+ template <fixed_string Name , typename T>
475475struct column_field : column_field_detail::base<T> {
476- using tag_type = Tag;
477476 using column_field_detail::base<T>::base;
478477 using column_field_detail::base<T>::operator =;
479478
480479 [[nodiscard]] static constexpr std::string_view column_name () noexcept {
481- return detail::tag_to_column_name<Tag>() ;
480+ return Name ;
482481 }
483482};
484483
485- // ===================================================================
486- // COLUMN_FIELD convenience macro
487- // ===================================================================
488-
489- /* *
490- * COLUMN_FIELD(tag, type) — declares a column field with a member variable.
491- *
492- * Expands to:
493- * struct tag_tag {};
494- * using tag = column_field<tag_tag, type>;
495- * tag tag_;
496- *
497- * Example (inside a struct/class body):
498- * COLUMN_FIELD(id, uint32_t)
499- * COLUMN_FIELD(ticker, varchar_field<32>)
500- * COLUMN_FIELD(sector, std::optional<varchar_field<64>>)
501- *
502- * SQL column names: "id", "ticker", "sector"
503- */
504- #define COLUMN_FIELD (tag, type ) \
505- struct tag ##_tag {}; \
506- using tag = ::ds_mysql::column_field<tag##_tag, type>; \
507- tag tag##_
508-
509484// ===================================================================
510485// ColumnFieldType concept
511486// ===================================================================
@@ -514,8 +489,8 @@ struct column_field : column_field_detail::base<T> {
514489 * ColumnFieldType<T> — satisfied by any type that publicly derives from
515490 * column_field_tag and exposes a value_type alias.
516491 *
517- * Only satisfied by the tagged form:
518- * using id = column_field<struct id_tag , uint32_t>;
492+ * Only satisfied by the named form:
493+ * using id = column_field<"id" , uint32_t>;
519494 */
520495template <typename T>
521496concept ColumnFieldType = std::derived_from<T, column_field_tag> && requires { typename T::value_type; };
0 commit comments