From ad79f7f35b154bf2123f85fde29745b7fb8d8455 Mon Sep 17 00:00:00 2001 From: Robert Adam Date: Tue, 24 Oct 2023 19:24:53 +0200 Subject: [PATCH] Bind blobs to actual blob objects This ensures that when binding blobs dynamically (e.g. in a row), they are properly represented as a soci::blob object and not by a std::string. --- include/soci/statement.h | 5 +++++ src/core/statement.cpp | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/soci/statement.h b/include/soci/statement.h index b356762e0..6d08187b8 100644 --- a/include/soci/statement.h +++ b/include/soci/statement.h @@ -16,6 +16,7 @@ #include "soci/use.h" #include "soci/soci-backend.h" #include "soci/row.h" +#include "soci/blob.h" // std #include #include @@ -164,6 +165,10 @@ class SOCI_DECL statement_impl SOCI_NOT_COPYABLE(statement_impl) }; +template<> +void statement_impl::into_row(); + + } // namespace details // Statement is a handle class for statement_impl diff --git a/src/core/statement.cpp b/src/core/statement.cpp index 4bf9f0e79..4a5dc9cc8 100644 --- a/src/core/statement.cpp +++ b/src/core/statement.cpp @@ -6,6 +6,8 @@ // #define SOCI_SOURCE +#include "soci/blob.h" +#include "soci/blob-exchange.h" #include "soci/statement.h" #include "soci/session.h" #include "soci/into-type.h" @@ -664,6 +666,12 @@ void statement_impl::bind_into() into_row(); } +template<> +void statement_impl::bind_into() +{ + into_row(); +} + void statement_impl::describe() { row_->clean_up(); @@ -686,7 +694,7 @@ void statement_impl::describe() bind_into(); break; case dt_blob: - bind_into(); + bind_into(); break; case dt_xml: bind_into(); @@ -825,3 +833,12 @@ statement_impl::rethrow_current_exception_with_context(char const* operation) throw; } } + +template<> +void statement_impl::into_row() +{ + blob * b = new blob(session_); + indicator * ind = new indicator(i_ok); + row_->add_holder(b, ind); + exchange_for_row(into(*b, *ind)); +}