2525#include " ds_mysql/name_reflection.hpp"
2626#include " ds_mysql/schema_generator.hpp"
2727#include " ds_mysql/sql_temporal.hpp"
28- #include " ds_mysql/varchar_field .hpp"
28+ #include " ds_mysql/sql_varchar .hpp"
2929
3030namespace ds_mysql {
3131
@@ -236,7 +236,7 @@ inline std::string format_time(std::chrono::microseconds dur, uint32_t fractiona
236236 * to_sql_value — convert a typed C++ value to its SQL literal representation.
237237 *
238238 * Handles: column_field<T> wrappers, std::optional<T>, datetime_type, bool,
239- * integral types, floating-point types, varchar_field <N>, std::string, and
239+ * integral types, floating-point types, varchar_type <N>, text_type , std::string, and
240240 * std::chrono::system_clock::time_point.
241241 */
242242template <typename T>
@@ -278,7 +278,7 @@ std::string to_sql_value(T const& v) {
278278 return std::to_string (v);
279279 } else if constexpr (std::floating_point<T>) {
280280 return std::to_string (v);
281- } else if constexpr (is_varchar_field_v <T>) {
281+ } else if constexpr (is_varchar_type_v<T> || is_text_type_v <T>) {
282282 return " '" + escape_sql_string (v.view ()) + " '" ;
283283 } else if constexpr (std::same_as<T, std::string>) {
284284 return " '" + escape_sql_string (v) + " '" ;
@@ -287,7 +287,7 @@ std::string to_sql_value(T const& v) {
287287 " to_sql_value: unsupported type. "
288288 " Supported: column_field<T>, optional<T>, datetime_type, timestamp_type, bool, "
289289 " integral types, floating-point types, float_type<P,S>, double_type<P,S>, "
290- " decimal_type<P,S>, varchar_field <N>, std::string, "
290+ " decimal_type<P,S>, varchar_type <N>, text_type , std::string, "
291291 " std::chrono::system_clock::time_point, time_type" );
292292 }
293293}
@@ -299,10 +299,11 @@ std::string to_sql_value(T const& v) {
299299// Constrains template parameters that must produce a valid SQL literal.
300300// ===================================================================
301301template <typename T>
302- concept SqlValue = ColumnFieldType<T> || is_optional_v<T> || is_datetime_type_v<T> || is_timestamp_type_v<T> ||
303- std::same_as<T, std::chrono::system_clock::time_point> || is_time_type_v<T> ||
304- std::same_as<T, bool > || std::integral<T> || std::floating_point<T> ||
305- is_formatted_numeric_type_v<T> || is_varchar_field_v<T> || std::same_as<T, std::string>;
302+ concept SqlValue =
303+ ColumnFieldType<T> || is_optional_v<T> || is_datetime_type_v<T> || is_timestamp_type_v<T> ||
304+ std::same_as<T, std::chrono::system_clock::time_point> || is_time_type_v<T> || std::same_as<T, bool > ||
305+ std::integral<T> || std::floating_point<T> || is_formatted_numeric_type_v<T> || is_varchar_type_v<T> ||
306+ is_text_type_v<T> || std::same_as<T, std::string>;
306307
307308// ===================================================================
308309// where_condition — a typed SQL WHERE fragment
@@ -655,7 +656,7 @@ struct col_expr {
655656 using value_type = typename Col::value_type;
656657
657658 // Operators accept value_type directly; callers must construct explicitly
658- // (e.g. col_ref<trade::code> == varchar_field <32>{"AAPL"}).
659+ // (e.g. col_ref<trade::code> == varchar_type <32>{"AAPL"}).
659660 [[nodiscard]] where_condition operator ==(value_type const & val) const {
660661 return equal<Col>(Col{val});
661662 }
@@ -4948,8 +4949,10 @@ T from_mysql_value_nonnull(std::string_view sv) {
49484949 return sv != " 0" && sv != " false" && !sv.empty ();
49494950 } else if constexpr (std::same_as<T, std::string>) {
49504951 return std::string{sv};
4951- } else if constexpr (is_varchar_field_v <T>) {
4952+ } else if constexpr (is_varchar_type_v <T>) {
49524953 return T::create (sv).value_or (T{});
4954+ } else if constexpr (is_text_type_v<T>) {
4955+ return T{sv};
49534956 } else if constexpr (std::same_as<T, std::chrono::system_clock::time_point>) {
49544957 std::istringstream ss{std::string{sv}};
49554958 std::tm tm{};
@@ -4980,7 +4983,7 @@ T from_mysql_value_nonnull(std::string_view sv) {
49804983 static_assert (false ,
49814984 " Unsupported type for MySQL deserialization. "
49824985 " Supported: uint32_t, int32_t, uint64_t, int64_t, float, double, float_type<P,S>, "
4983- " double_type<P,S>, decimal_type<P,S>, bool, std::string, varchar_field <N>, "
4986+ " double_type<P,S>, decimal_type<P,S>, bool, std::string, varchar_type <N>, text_type , "
49844987 " std::chrono::system_clock::time_point (for DATETIME/TIMESTAMP), time_type, "
49854988 " and their std::optional variants." );
49864989 }
0 commit comments