From 9c8e402692c2eb3a0d03d0db373cc86af11d4f48 Mon Sep 17 00:00:00 2001 From: Sascha Kuehl Date: Tue, 23 Jan 2024 07:20:34 +0100 Subject: [PATCH] added blob interface to backend binder classes --- backends/mysql/include/mysql_parameter_binder.hpp | 2 ++ backends/mysql/src/mysql_parameter_binder.cpp | 5 +++++ backends/postgres/include/postgres_parameter_binder.h | 2 ++ backends/postgres/src/postgres_dialect.cpp | 6 +++++- backends/postgres/src/postgres_parameter_binder.cpp | 5 +++++ 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/backends/mysql/include/mysql_parameter_binder.hpp b/backends/mysql/include/mysql_parameter_binder.hpp index ef37467..74f2aaf 100644 --- a/backends/mysql/include/mysql_parameter_binder.hpp +++ b/backends/mysql/include/mysql_parameter_binder.hpp @@ -54,6 +54,8 @@ public: void bind(size_t pos, const std::string &string) override; void bind(size_t pos, const std::string &x, size_t size) override; + void bind(size_t pos, const utils::blob &blob) override; + [[nodiscard]] std::vector& bind_params(); private: diff --git a/backends/mysql/src/mysql_parameter_binder.cpp b/backends/mysql/src/mysql_parameter_binder.cpp index 655fa8a..213f08d 100644 --- a/backends/mysql/src/mysql_parameter_binder.cpp +++ b/backends/mysql/src/mysql_parameter_binder.cpp @@ -179,6 +179,11 @@ void mysql_parameter_binder::bind(size_t pos, const std::string &str, size_t siz detail::bind_value(MYSQL_TYPE_VAR_STRING, str.data(), size, bind_params_[pos], is_null_vector[pos].is_null); } +void mysql_parameter_binder::bind(size_t pos, const utils::blob &blob) +{ + +} + std::vector &mysql_parameter_binder::bind_params() { return bind_params_; diff --git a/backends/postgres/include/postgres_parameter_binder.h b/backends/postgres/include/postgres_parameter_binder.h index 441cb94..6f349ff 100644 --- a/backends/postgres/include/postgres_parameter_binder.h +++ b/backends/postgres/include/postgres_parameter_binder.h @@ -30,6 +30,8 @@ public: void bind(size_t pos, const std::string &string) override; void bind(size_t pos, const std::string &x, size_t size) override; + void bind(size_t pos, const utils::blob &blob) override; + const std::vector& params() const; private: diff --git a/backends/postgres/src/postgres_dialect.cpp b/backends/postgres/src/postgres_dialect.cpp index c854c0f..d28ba05 100644 --- a/backends/postgres/src/postgres_dialect.cpp +++ b/backends/postgres/src/postgres_dialect.cpp @@ -2,13 +2,17 @@ #include "matador/sql/dialect_builder.hpp" -[[maybe_unused]] const matador::sql::dialect* get_dialect() { +[[maybe_unused]] const matador::sql::dialect *get_dialect() +{ using namespace matador::sql; const static dialect d = dialect_builder::builder() .create() .with_placeholder_func([](size_t index) { return "$" + std::to_string(index); }) + .with_data_type_replace_map({ + {data_type_t::type_blob, "BYTEA"} + }) .with_default_schema_name("public") .build(); return &d; diff --git a/backends/postgres/src/postgres_parameter_binder.cpp b/backends/postgres/src/postgres_parameter_binder.cpp index 9537204..f62a213 100644 --- a/backends/postgres/src/postgres_parameter_binder.cpp +++ b/backends/postgres/src/postgres_parameter_binder.cpp @@ -134,6 +134,11 @@ void postgres_parameter_binder::bind(size_t pos, const std::string &str, size_t bind(pos, str); } +void postgres_parameter_binder::bind(size_t pos, const utils::blob &blob) +{ + +} + const std::vector &postgres_parameter_binder::params() const { return params_;