Skip to content

Commit

Permalink
fix bool on pg and mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacyking committed Jan 4, 2024
1 parent d9d652b commit 15bf474
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
18 changes: 14 additions & 4 deletions include/mysql.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,13 @@ class mysql {
param.buffer = const_cast<void *>(static_cast<const void *>(&value));
}
else if constexpr (std::is_arithmetic_v<U>) {
param.buffer_type =
(enum_field_types)ormpp_mysql::type_to_id(identity<U>{});
if constexpr (std::is_same_v<bool, U>) {
param.buffer_type = MYSQL_TYPE_TINY;
}
else {
param.buffer_type =
(enum_field_types)ormpp_mysql::type_to_id(identity<U>{});
}
param.buffer = const_cast<void *>(static_cast<const void *>(&value));
}
else if constexpr (std::is_same_v<std::string, U>) {
Expand Down Expand Up @@ -214,8 +219,13 @@ class mysql {
param_bind.buffer = const_cast<void *>(static_cast<const void *>(&value));
}
else if constexpr (std::is_arithmetic_v<U>) {
param_bind.buffer_type =
(enum_field_types)ormpp_mysql::type_to_id(identity<U>{});
if constexpr (std::is_same_v<bool, U>) {
param_bind.buffer_type = MYSQL_TYPE_TINY;
}
else {
param_bind.buffer_type =
(enum_field_types)ormpp_mysql::type_to_id(identity<U>{});
}
param_bind.buffer = const_cast<void *>(static_cast<const void *>(&value));
}
else if constexpr (std::is_same_v<std::string, U>) {
Expand Down
1 change: 0 additions & 1 deletion include/type_mapping.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ struct identity {};

#ifdef ORMPP_ENABLE_MYSQL
namespace ormpp_mysql {
REGISTER_TYPE(bool, MYSQL_TYPE_BOOL)
REGISTER_TYPE(char, MYSQL_TYPE_TINY)
REGISTER_TYPE(short, MYSQL_TYPE_SHORT)
REGISTER_TYPE(int, MYSQL_TYPE_LONG)
Expand Down

0 comments on commit 15bf474

Please sign in to comment.