diff --git a/ormpp/sqlite.hpp b/ormpp/sqlite.hpp index 02f27ab..4a3d38f 100644 --- a/ormpp/sqlite.hpp +++ b/ormpp/sqlite.hpp @@ -572,6 +572,10 @@ class sqlite { return SQLITE_OK == sqlite3_bind_text(stmt_, i, value, strlen(value), nullptr); } + else if constexpr (std::is_same_v, U>) { + return SQLITE_OK == + sqlite3_bind_blob(stmt_, i, value.data(),static_cast(value.size()), nullptr); + } #ifdef ORMPP_WITH_CSTRING else if constexpr (std::is_same_v) { return SQLITE_OK == sqlite3_bind_text(stmt_, i, value.GetString(), @@ -624,6 +628,10 @@ class sqlite { else if constexpr (iguana::c_array_v) { memcpy(value, sqlite3_column_text(stmt_, i), sizeof(U)); } + else if constexpr (std::is_same_v, U>) { + value.reserve(sqlite3_column_bytes(stmt_, i)); + memcpy(value.data(),(const char *)sqlite3_column_blob(stmt_, i),(size_t)sqlite3_column_bytes(stmt_, i)); + } #ifdef ORMPP_WITH_CSTRING else if constexpr (std::is_same_v) { value.SetString((const char *)sqlite3_column_text(stmt_, i)); diff --git a/ormpp/type_mapping.hpp b/ormpp/type_mapping.hpp index 7699571..9acfcdb 100644 --- a/ormpp/type_mapping.hpp +++ b/ormpp/type_mapping.hpp @@ -85,6 +85,8 @@ namespace ormpp_sqlite { REGISTER_TYPE(int, SQLITE_INTEGER) REGISTER_TYPE(double, SQLITE_FLOAT) +using blob = std::vector; + inline int type_to_id(identity) noexcept { return SQLITE_TEXT; } inline std::string id_to_type( std::integral_constant) noexcept { @@ -113,6 +115,7 @@ inline constexpr auto type_to_name(identity) noexcept { inline constexpr auto type_to_name(identity) noexcept { return "INTEGER"sv; } +inline constexpr auto type_to_name(identity) noexcept { return "BLOB"sv; } inline auto type_to_name(identity) noexcept { return "TEXT"sv; } template inline auto type_to_name(identity>) noexcept {