Skip to content

Commit

Permalink
change is_char_array_v to iguana::array_v
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacyking committed Jun 18, 2024
1 parent 9718927 commit 6d840f1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ormpp/postgresql.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ class postgresql {
sprintf(temp.data(), "%f", value);
param_values.push_back(std::move(temp));
}
else if constexpr (std::is_same_v<std::string, U>) {
else if constexpr (iguana::array_v<U> || std::is_same_v<std::string, U>) {
std::vector<char> temp = {};
std::copy(value.data(), value.data() + value.size() + 1,
std::back_inserter(temp));
Expand All @@ -719,10 +719,6 @@ class postgresql {
std::copy(value, value + sizeof(U), std::back_inserter(temp));
param_values.push_back(std::move(temp));
}
else if constexpr (iguana::array_v<U>) {
auto p = PQgetvalue(res_, row, i);
memcpy(value.data(), p, value.size());
}
else {
static_assert(!sizeof(U), "this type has not supported yet");
}
Expand Down Expand Up @@ -753,13 +749,17 @@ class postgresql {
else if constexpr (std::is_floating_point_v<U>) {
value = std::atof(PQgetvalue(res_, row, i));
}
else if constexpr (iguana::array_v<U> || std::is_same_v<std::string, U>) {
else if constexpr (std::is_same_v<std::string, U>) {
value = PQgetvalue(res_, row, i);
}
else if constexpr (iguana::c_array_v<U>) {
auto p = PQgetvalue(res_, row, i);
memcpy(value, p, sizeof(U));
}
else if constexpr (iguana::array_v<U>) {
auto p = PQgetvalue(res_, row, i);
memcpy(value.data(), p, value.size());
}
else {
static_assert(!sizeof(U), "this type has not supported yet");
}
Expand Down

0 comments on commit 6d840f1

Please sign in to comment.