39 static std::string
to_sql_string(
const int& value) {
return std::to_string(value); }
49 static std::string
to_sql_string(
const double& value) {
return std::to_string(value); }
51 static double from_sql_string(
const std::string& value) {
return std::stod(value); }
61 std::string escaped = value;
63 while ((pos = escaped.find(
'\'', pos)) != std::string::npos) {
64 escaped.insert(pos, 1,
'\'');
67 return "'" + escaped +
"'";
72 if (value.size() >= 2 && value.front() ==
'\'' && value.back() ==
'\'') {
73 std::string unquoted = value.substr(1, value.size() - 2);
76 while ((pos = unquoted.find(
"''", pos)) != std::string::npos) {
77 unquoted.erase(pos, 1);
91 static std::string
to_sql_string(
const bool& value) {
return value ?
"1" :
"0"; }
94 return value ==
"1" || value ==
"true" || value ==
"TRUE";
103 static std::string
to_sql_string(
const float& value) {
return std::to_string(value); }
113 static std::string
to_sql_string(
const long& value) {
return std::to_string(value); }
123 static std::string
to_sql_string(
const long long& value) {
return std::to_string(value); }
125 static long long from_sql_string(
const std::string& value) {
return std::stoll(value); }
142 if (value ==
"NULL") {
static bool from_sql_string(const std::string &value)
static std::string to_sql_string(const bool &value)
static std::string to_sql_string(const double &value)
static double from_sql_string(const std::string &value)
static float from_sql_string(const std::string &value)
static std::string to_sql_string(const float &value)
static std::string to_sql_string(const int &value)
static int from_sql_string(const std::string &value)
static std::string to_sql_string(const long &value)
static long from_sql_string(const std::string &value)
static std::string to_sql_string(const long long &value)
static long long from_sql_string(const std::string &value)
static std::string to_sql_string(const std::nullopt_t &)
static std::nullopt_t from_sql_string(const std::string &)
static std::string to_sql_string(const std::optional< T > &value)
static std::optional< T > from_sql_string(const std::string &value)
static std::string to_sql_string(const std::string &value)
static std::string from_sql_string(const std::string &value)
Contains schema definition components.
static constexpr bool nullable
Whether this type can be NULL.
static T from_sql_string(const std::string &value)
Parse a SQL string representation to a C++ value.
static std::string to_sql_string(const T &value)
Convert a C++ value to a SQL string representation.
static constexpr auto sql_type_name
The SQL type name for this C++ type.