added mysql data type string conversion
This commit is contained in:
parent
9355f7ea27
commit
b158b41556
|
|
@ -110,8 +110,41 @@ sql::null_option to_null_option(unsigned int flags)
|
||||||
|
|
||||||
sql::data_type_t string2type(const std::string &type_string)
|
sql::data_type_t string2type(const std::string &type_string)
|
||||||
{
|
{
|
||||||
// if (strcmp(type_string.c_str(), "int")
|
if (strncmp(type_string.c_str(), "tinyint", 7) == 0) {
|
||||||
return sql::data_type_t::type_unknown;
|
return sql::data_type_t::type_char;
|
||||||
|
} else if (strncmp(type_string.c_str(), "smallint", 8) == 0) {
|
||||||
|
if (strstr(type_string.c_str(), "unsigned") != nullptr) {
|
||||||
|
return sql::data_type_t::type_unsigned_short;
|
||||||
|
} else {
|
||||||
|
return sql::data_type_t::type_short;
|
||||||
|
}
|
||||||
|
} else if (strncmp(type_string.c_str(), "int", 3) == 0) {
|
||||||
|
if (strstr(type_string.c_str(), "unsigned") != nullptr) {
|
||||||
|
return sql::data_type_t::type_unsigned_int;
|
||||||
|
} else {
|
||||||
|
return sql::data_type_t::type_int;
|
||||||
|
}
|
||||||
|
} else if (strncmp(type_string.c_str(), "bigint", 6) == 0) {
|
||||||
|
if (strstr(type_string.c_str(), "unsigned") != nullptr) {
|
||||||
|
return sql::data_type_t::type_unsigned_long_long;
|
||||||
|
} else {
|
||||||
|
return sql::data_type_t::type_long_long;
|
||||||
|
}
|
||||||
|
} else if (strcmp(type_string.c_str(), "date") == 0) {
|
||||||
|
return sql::data_type_t::type_date;
|
||||||
|
} else if (strncmp(type_string.c_str(), "datetime", 8) == 0) {
|
||||||
|
return sql::data_type_t::type_time;
|
||||||
|
} else if (strcmp(type_string.c_str(), "float") == 0) {
|
||||||
|
return sql::data_type_t::type_float;
|
||||||
|
} else if (strcmp(type_string.c_str(), "double") == 0) {
|
||||||
|
return sql::data_type_t::type_double;
|
||||||
|
} else if (strncmp(type_string.c_str(), "varchar", 7) == 0) {
|
||||||
|
return sql::data_type_t::type_varchar;
|
||||||
|
} else if (strncmp(type_string.c_str(), "text", 4) == 0) {
|
||||||
|
return sql::data_type_t::type_text;
|
||||||
|
} else {
|
||||||
|
return sql::data_type_t::type_unknown;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct type_info
|
struct type_info
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue