renamed blob to blob_type_t

This commit is contained in:
Sascha Kühl 2026-01-07 09:21:10 +01:00
parent 41f6c9f516
commit f30c250a20
44 changed files with 88 additions and 80 deletions

View File

@ -38,7 +38,7 @@ public:
utils::result<std::vector<object::attribute>, utils::error> describe(const std::string& table) override; utils::result<std::vector<object::attribute>, utils::error> describe(const std::string& table) override;
utils::result<bool, utils::error> exists(const std::string &schema_name, const std::string &table_name) override; utils::result<bool, utils::error> exists(const std::string &schema_name, const std::string &table_name) override;
[[nodiscard]] std::string to_escaped_string( const utils::blob& value ) const override; [[nodiscard]] std::string to_escaped_string( const utils::blob_type_t& value ) const override;
private: private:
[[nodiscard]] static std::string generate_statement_name(const sql::query_context &query) ; [[nodiscard]] static std::string generate_statement_name(const sql::query_context &query) ;

View File

@ -38,7 +38,7 @@ public:
void write_value(size_t pos, const char *x, size_t size) override; void write_value(size_t pos, const char *x, size_t size) override;
void write_value(size_t pos, const std::string &x) override; void write_value(size_t pos, const std::string &x) override;
void write_value(size_t pos, const std::string &x, size_t size) override; void write_value(size_t pos, const std::string &x, size_t size) override;
void write_value(size_t pos, const utils::blob &x) override; void write_value(size_t pos, const utils::blob_type_t &x) override;
void write_value(size_t pos, const utils::value &x, size_t size) override; void write_value(size_t pos, const utils::value &x, size_t size) override;
[[nodiscard]] const bind_data& params() const; [[nodiscard]] const bind_data& params() const;

View File

@ -28,7 +28,7 @@ public:
void read_value(const char *, size_t, char *, size_t) override {} void read_value(const char *, size_t, char *, size_t) override {}
void read_value(const char *, size_t, std::string &) override {} void read_value(const char *, size_t, std::string &) override {}
void read_value(const char *, size_t, std::string &, size_t) override {} void read_value(const char *, size_t, std::string &, size_t) override {}
void read_value(const char *, size_t, utils::blob &) override {} void read_value(const char *, size_t, utils::blob_type_t &) override {}
void read_value(const char *, size_t, utils::value &, size_t) override {} void read_value(const char *, size_t, utils::value &, size_t) override {}
}; };
@ -62,7 +62,7 @@ public:
void read_value(const char *id, size_t index, char *value, size_t size) override; void read_value(const char *id, size_t index, char *value, size_t size) override;
void read_value(const char *id, size_t index, std::string &value) override; void read_value(const char *id, size_t index, std::string &value) override;
void read_value(const char *id, size_t index, std::string &value, size_t size) override; void read_value(const char *id, size_t index, std::string &value, size_t size) override;
void read_value(const char *id, size_t index, utils::blob &value) override; void read_value(const char *id, size_t index, utils::blob_type_t &value) override;
void read_value(const char *id, size_t index, utils::value &val, size_t size) override; void read_value(const char *id, size_t index, utils::value &val, size_t size) override;
protected: protected:

View File

@ -293,7 +293,7 @@ utils::result<bool, utils::error> postgres_connection::exists(const std::string
return utils::ok(*result == 1); return utils::ok(*result == 1);
} }
std::string postgres_connection::to_escaped_string(const utils::blob &value) const { std::string postgres_connection::to_escaped_string(const utils::blob_type_t &value) const {
size_t escapedDataLength; size_t escapedDataLength;
unsigned char *escapedData = PQescapeByteaConn(conn_, value.data(), value.size(), &escapedDataLength); unsigned char *escapedData = PQescapeByteaConn(conn_, value.data(), value.size(), &escapedDataLength);

View File

@ -148,7 +148,7 @@ void postgres_parameter_binder::write_value(const size_t pos, const utils::time_
void postgres_parameter_binder::write_value(size_t pos, const utils::timestamp &x) { void postgres_parameter_binder::write_value(size_t pos, const utils::timestamp &x) {
} }
void postgres_parameter_binder::write_value(const size_t pos, const utils::blob &x) { void postgres_parameter_binder::write_value(const size_t pos, const utils::blob_type_t &x) {
bind_data_.bytes[pos] = x; bind_data_.bytes[pos] = x;
bind_data_.values[pos] = reinterpret_cast<char *>(bind_data_.bytes[pos].data()); bind_data_.values[pos] = reinterpret_cast<char *>(bind_data_.bytes[pos].data());
bind_data_.lengths[pos] = static_cast<int>(bind_data_.bytes[pos].size()); bind_data_.lengths[pos] = static_cast<int>(bind_data_.bytes[pos].size());

View File

@ -145,7 +145,7 @@ void postgres_result_reader::read_value(const char * /*id*/, const size_t index,
value.assign(column(index)); value.assign(column(index));
} }
void postgres_result_reader::read_value(const char * /*id*/, const size_t index, utils::blob &value) { void postgres_result_reader::read_value(const char * /*id*/, const size_t index, utils::blob_type_t &value) {
const auto *data = reinterpret_cast<const unsigned char *>(column(index)); const auto *data = reinterpret_cast<const unsigned char *>(column(index));
size_t length; size_t length;
@ -164,11 +164,11 @@ void set_value(const char *str, utils::value &value) {
} }
template<> template<>
void set_value<utils::blob>(const char *str, utils::value &value) { void set_value<utils::blob_type_t>(const char *str, utils::value &value) {
size_t length; size_t length;
unsigned char *unescaped = PQunescapeBytea(reinterpret_cast<const unsigned char *>(str), &length); unsigned char *unescaped = PQunescapeBytea(reinterpret_cast<const unsigned char *>(str), &length);
value = utils::blob(unescaped, unescaped + length); value = utils::blob_type_t(unescaped, unescaped + length);
PQfreemem(unescaped); PQfreemem(unescaped);
} }
@ -232,7 +232,7 @@ void postgres_result_reader::read_value(const char * /*id*/, const size_t index,
break; break;
} }
case utils::basic_type::Blob: { case utils::basic_type::Blob: {
set_value<utils::blob>(column(index), val); set_value<utils::blob_type_t>(column(index), val);
break; break;
} }
case utils::basic_type::Unknown: case utils::basic_type::Unknown:

View File

@ -30,7 +30,7 @@ static const matador::utils::enum_mapper<CollectionCenterType> CollectionCenterT
struct CollectionCenter : core::Model { struct CollectionCenter : core::Model {
std::string name; std::string name;
matador::utils::blob symbol; matador::utils::blob_type_t symbol;
CollectionCenterType type{CollectionCenterType::NoType}; CollectionCenterType type{CollectionCenterType::NoType};
matador::object::collection<matador::object::object_ptr<User>> users; matador::object::collection<matador::object::object_ptr<User>> users;

View File

@ -40,7 +40,7 @@ struct Scenario : core::Model {
std::string name; std::string name;
ScenarioMode mode{ScenarioMode::InvalidMode}; ScenarioMode mode{ScenarioMode::InvalidMode};
std::string description; std::string description;
matador::utils::blob symbol; matador::utils::blob_type_t symbol;
ScenarioState state{ScenarioState::InvalidState}; ScenarioState state{ScenarioState::InvalidState};
matador::object::collection<matador::object::object_ptr<CollectionCenter>> collection_center; matador::object::collection<matador::object::object_ptr<CollectionCenter>> collection_center;

View File

@ -16,7 +16,7 @@ struct UserDirectory;
struct User : core::Model { struct User : core::Model {
std::string name; std::string name;
matador::utils::blob symbol; matador::utils::blob_type_t symbol;
std::string salt; std::string salt;
std::string password; std::string password;
LockType lock_type{LockType::NoLock}; LockType lock_type{LockType::NoLock};

View File

@ -45,7 +45,7 @@ public:
void write_value(size_t pos, const char* x, size_t size) override; void write_value(size_t pos, const char* x, size_t size) override;
void write_value(size_t pos, const std::string& x) override; void write_value(size_t pos, const std::string& x) override;
void write_value(size_t pos, const std::string& x, size_t size) override; void write_value(size_t pos, const std::string& x, size_t size) override;
void write_value(size_t pos, const utils::blob& x) override; void write_value(size_t pos, const utils::blob_type_t& x) override;
void write_value(size_t pos, const utils::value& x, size_t size) override; void write_value(size_t pos, const utils::value& x, size_t size) override;
private: private:

View File

@ -34,7 +34,7 @@ struct basic_type_to_string_visitor
void operator()(const utils::date_type_t &x) { result = writer->to_string(x); } void operator()(const utils::date_type_t &x) { result = writer->to_string(x); }
void operator()(const utils::time_type_t &x) { result = writer->to_string(x); } void operator()(const utils::time_type_t &x) { result = writer->to_string(x); }
void operator()(const utils::timestamp &x) { result = writer->to_string(x); } void operator()(const utils::timestamp &x) { result = writer->to_string(x); }
void operator()(const utils::blob &x) { result = writer->to_string(x); } void operator()(const utils::blob_type_t &x) { result = writer->to_string(x); }
attribute_string_writer *writer{}; attribute_string_writer *writer{};
sql::query_context &query; sql::query_context &query;

View File

@ -78,7 +78,7 @@ public:
void write_value(size_t pos, const char *x, size_t size) override; void write_value(size_t pos, const char *x, size_t size) override;
void write_value(size_t pos, const std::string &x) override; void write_value(size_t pos, const std::string &x) override;
void write_value(size_t pos, const std::string &x, size_t size) override; void write_value(size_t pos, const std::string &x, size_t size) override;
void write_value(size_t pos, const utils::blob &x) override; void write_value(size_t pos, const utils::blob_type_t &x) override;
void write_value(size_t pos, const utils::value &x, size_t size) override; void write_value(size_t pos, const utils::value &x, size_t size) override;
private: private:

View File

@ -37,7 +37,7 @@ public:
using sql_func_to_string_map = std::unordered_map<sql_function_t, std::string>; using sql_func_to_string_map = std::unordered_map<sql_function_t, std::string>;
using next_placeholder_func = std::function<std::string(size_t)>; using next_placeholder_func = std::function<std::string(size_t)>;
using to_escaped_string_func = std::function<std::string(const utils::blob &)>; using to_escaped_string_func = std::function<std::string(const utils::blob_type_t &)>;
public: public:
[[nodiscard]] const std::string& token_at(dialect_token token) const; [[nodiscard]] const std::string& token_at(dialect_token token) const;
@ -115,7 +115,7 @@ public:
*/ */
[[nodiscard]] std::string next_placeholder(const std::vector<std::string> &bind_vars) const; [[nodiscard]] std::string next_placeholder(const std::vector<std::string> &bind_vars) const;
[[nodiscard]] std::string to_escaped_string(const utils::blob &value, const connection_impl *conn = nullptr) const; [[nodiscard]] std::string to_escaped_string(const utils::blob_type_t &value, const connection_impl *conn = nullptr) const;
/** /**
* Returns the default schema name. * Returns the default schema name.
@ -183,7 +183,7 @@ private:
friend class dialect_builder; friend class dialect_builder;
next_placeholder_func placeholder_func_ = [](size_t) { return "?"; }; next_placeholder_func placeholder_func_ = [](size_t) { return "?"; };
to_escaped_string_func to_escaped_string_func_ = [](const utils::blob &val) { return utils::to_string(val); }; to_escaped_string_func to_escaped_string_func_ = [](const utils::blob_type_t &val) { return utils::to_string(val); };
escape_identifier_t identifier_escape_type_ = escape_identifier_t::ESCAPE_BOTH_SAME; escape_identifier_t identifier_escape_type_ = escape_identifier_t::ESCAPE_BOTH_SAME;

View File

@ -13,7 +13,7 @@
#include "matador/utils/version.hpp" #include "matador/utils/version.hpp"
namespace matador::utils { namespace matador::utils {
using blob = std::vector<unsigned char>; using blob_type_t = std::vector<unsigned char>;
} }
namespace matador::sql { namespace matador::sql {
@ -43,7 +43,7 @@ public:
[[nodiscard]] const class dialect &dialect() const; [[nodiscard]] const class dialect &dialect() const;
[[nodiscard]] virtual std::string to_escaped_string(const utils::blob &value) const = 0; [[nodiscard]] virtual std::string to_escaped_string(const utils::blob_type_t &value) const = 0;
[[nodiscard]] const connection_info &info() const; [[nodiscard]] const connection_info &info() const;
protected: protected:

View File

@ -31,7 +31,7 @@ public:
virtual void read_value(const char *id, size_t index, char *value, size_t size) = 0; virtual void read_value(const char *id, size_t index, char *value, size_t size) = 0;
virtual void read_value(const char *id, size_t index, std::string &value) = 0; virtual void read_value(const char *id, size_t index, std::string &value) = 0;
virtual void read_value(const char *id, size_t index, std::string &value, size_t size) = 0; virtual void read_value(const char *id, size_t index, std::string &value, size_t size) = 0;
virtual void read_value(const char *id, size_t index, blob &value) = 0; virtual void read_value(const char *id, size_t index, blob_type_t &value) = 0;
virtual void read_value(const char *id, size_t index, value &value, size_t size) = 0; virtual void read_value(const char *id, size_t index, value &value, size_t size) = 0;
}; };

View File

@ -32,7 +32,7 @@ public:
virtual void write_value(size_t pos, const char *x, size_t size) = 0; virtual void write_value(size_t pos, const char *x, size_t size) = 0;
virtual void write_value(size_t pos, const std::string &x) = 0; virtual void write_value(size_t pos, const std::string &x) = 0;
virtual void write_value(size_t pos, const std::string &x, size_t size) = 0; virtual void write_value(size_t pos, const std::string &x, size_t size) = 0;
virtual void write_value(size_t pos, const blob &x) = 0; virtual void write_value(size_t pos, const blob_type_t &x) = 0;
virtual void write_value(size_t pos, const value &x, size_t size) = 0; virtual void write_value(size_t pos, const value &x, size_t size) = 0;
}; };

View File

@ -34,7 +34,7 @@ public:
void operator()(date_type_t &x) { this->convert(x); } void operator()(date_type_t &x) { this->convert(x); }
void operator()(time_type_t &x) { this->convert(x); } void operator()(time_type_t &x) { this->convert(x); }
void operator()(timestamp &x) { this->convert(x); } void operator()(timestamp &x) { this->convert(x); }
void operator()(blob &x) { this->convert(x); } void operator()(blob_type_t &x) { this->convert(x); }
private: private:
result<Type, conversion_error> result_{}; result<Type, conversion_error> result_{};

View File

@ -158,7 +158,7 @@ result<DestType, conversion_error> to(const std::string &source, std::enable_if_
} }
template < typename DestType > template < typename DestType >
result<DestType, conversion_error> to(const blob &source, std::enable_if_t<std::is_same_v<DestType, blob>>* = nullptr) { result<DestType, conversion_error> to(const blob_type_t &source, std::enable_if_t<std::is_same_v<DestType, blob_type_t>>* = nullptr) {
return ok(source); return ok(source);
} }
@ -211,7 +211,7 @@ result<DestType, conversion_error> to(const SourceType &source, std::enable_if_t
} }
template < typename DestType, typename SourceType > template < typename DestType, typename SourceType >
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<SourceType, blob> &&std::is_same_v<DestType, std::string>>* = nullptr) { result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<SourceType, blob_type_t> &&std::is_same_v<DestType, std::string>>* = nullptr) {
return failure(conversion_error::NotConvertable); return failure(conversion_error::NotConvertable);
} }
@ -224,12 +224,12 @@ result<DestType, conversion_error> to(const SourceType &source, std::enable_if_t
} }
template < typename DestType, typename SourceType > template < typename DestType, typename SourceType >
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_arithmetic_v<DestType> && std::is_same_v<SourceType, blob>>* = nullptr) { result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_arithmetic_v<DestType> && std::is_same_v<SourceType, blob_type_t>>* = nullptr) {
return failure(conversion_error::NotConvertable); return failure(conversion_error::NotConvertable);
} }
template < typename DestType, typename SourceType > template < typename DestType, typename SourceType >
result<DestType, conversion_error> to(const SourceType &source, std::enable_if_t<std::is_integral_v<SourceType> && std::is_same_v<DestType, blob>>* = nullptr) { result<DestType, conversion_error> to(const SourceType &source, std::enable_if_t<std::is_integral_v<SourceType> && std::is_same_v<DestType, blob_type_t>>* = nullptr) {
DestType result; DestType result;
result.resize(sizeof(source)); result.resize(sizeof(source));
std::memcpy(result.data(), &source, sizeof(source)); std::memcpy(result.data(), &source, sizeof(source));
@ -238,17 +238,17 @@ result<DestType, conversion_error> to(const SourceType &source, std::enable_if_t
} }
template < typename DestType, typename SourceType > template < typename DestType, typename SourceType >
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_floating_point_v<SourceType> && std::is_same_v<DestType, blob>>* = nullptr) { result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_floating_point_v<SourceType> && std::is_same_v<DestType, blob_type_t>>* = nullptr) {
return failure(conversion_error::NotConvertable); return failure(conversion_error::NotConvertable);
} }
template < typename DestType, typename SourceType > template < typename DestType, typename SourceType >
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<SourceType, std::string> && std::is_same_v<DestType, blob>>* = nullptr) { result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<SourceType, std::string> && std::is_same_v<DestType, blob_type_t>>* = nullptr) {
return failure(conversion_error::NotConvertable); return failure(conversion_error::NotConvertable);
} }
template < typename DestType, typename SourceType > template < typename DestType, typename SourceType >
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<SourceType, const char*> && std::is_same_v<DestType, blob>>* = nullptr) { result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<SourceType, const char*> && std::is_same_v<DestType, blob_type_t>>* = nullptr) {
return failure(conversion_error::NotConvertable); return failure(conversion_error::NotConvertable);
} }
@ -353,17 +353,17 @@ result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_
} }
template < typename DestType, typename SourceType > template < typename DestType, typename SourceType >
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<blob, DestType> && std::is_same_v<date_type_t, SourceType>>* = nullptr) { result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<blob_type_t, DestType> && std::is_same_v<date_type_t, SourceType>>* = nullptr) {
return failure(conversion_error::NotConvertable); return failure(conversion_error::NotConvertable);
} }
template < typename DestType, typename SourceType > template < typename DestType, typename SourceType >
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<blob, DestType> && std::is_same_v<time_type_t, SourceType>>* = nullptr) { result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<blob_type_t, DestType> && std::is_same_v<time_type_t, SourceType>>* = nullptr) {
return failure(conversion_error::NotConvertable); return failure(conversion_error::NotConvertable);
} }
template < typename DestType, typename SourceType > template < typename DestType, typename SourceType >
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<blob, DestType> && std::is_same_v<timestamp, SourceType>>* = nullptr) { result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<blob_type_t, DestType> && std::is_same_v<timestamp, SourceType>>* = nullptr) {
return failure(conversion_error::NotConvertable); return failure(conversion_error::NotConvertable);
} }
@ -413,17 +413,17 @@ result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_
} }
template < typename DestType> template < typename DestType>
result<DestType, conversion_error> to(const blob &/*source*/, std::enable_if_t<std::is_same_v<date_type_t, DestType>>* = nullptr) { result<DestType, conversion_error> to(const blob_type_t &/*source*/, std::enable_if_t<std::is_same_v<date_type_t, DestType>>* = nullptr) {
return failure(conversion_error::NotConvertable); return failure(conversion_error::NotConvertable);
} }
template < typename DestType> template < typename DestType>
result<DestType, conversion_error> to(const blob &/*source*/, std::enable_if_t<std::is_same_v<time_type_t, DestType>>* = nullptr) { result<DestType, conversion_error> to(const blob_type_t &/*source*/, std::enable_if_t<std::is_same_v<time_type_t, DestType>>* = nullptr) {
return failure(conversion_error::NotConvertable); return failure(conversion_error::NotConvertable);
} }
template < typename DestType> template < typename DestType>
result<DestType, conversion_error> to(const blob &/*source*/, std::enable_if_t<std::is_same_v<timestamp, DestType>>* = nullptr) { result<DestType, conversion_error> to(const blob_type_t &/*source*/, std::enable_if_t<std::is_same_v<timestamp, DestType>>* = nullptr) {
return failure(conversion_error::NotConvertable); return failure(conversion_error::NotConvertable);
} }

View File

@ -131,10 +131,10 @@ struct data_type_traits<std::string, void> {
}; };
template<> template<>
struct data_type_traits<blob, void> { struct data_type_traits<blob_type_t, void> {
static basic_type type(std::size_t /*size*/) { return basic_type::Blob; } static basic_type type(std::size_t /*size*/) { return basic_type::Blob; }
static void read_value(attribute_reader &reader, const char *id, size_t index, utils::blob &value, size_t /*size*/ = 0); static void read_value(attribute_reader &reader, const char *id, size_t index, utils::blob_type_t &value, size_t /*size*/ = 0);
static void bind_value(attribute_writer &binder, size_t index, utils::blob &value, size_t /*size*/ = 0); static void bind_value(attribute_writer &binder, size_t index, utils::blob_type_t &value, size_t /*size*/ = 0);
}; };
template<> template<>

View File

@ -18,7 +18,7 @@ namespace matador::utils {
* @param data Binary data to be converted * @param data Binary data to be converted
* @return Binary data as string * @return Binary data as string
*/ */
MATADOR_UTILS_API std::string to_string(const blob &data); MATADOR_UTILS_API std::string to_string(const blob_type_t &data);
MATADOR_UTILS_API std::string to_string(const date_type_t &data); MATADOR_UTILS_API std::string to_string(const date_type_t &data);
MATADOR_UTILS_API std::string to_string(const time_type_t &data); MATADOR_UTILS_API std::string to_string(const time_type_t &data);

View File

@ -12,7 +12,7 @@ namespace matador::utils {
enum class basic_type : uint8_t; enum class basic_type : uint8_t;
using byte = unsigned char; using byte = unsigned char;
using blob = std::vector<byte>; using blob_type_t = std::vector<byte>;
using timestamp = std::chrono::system_clock::time_point; using timestamp = std::chrono::system_clock::time_point;
struct date_type_t; struct date_type_t;
@ -25,7 +25,7 @@ using database_type = std::variant<
bool, bool,
const char*, const char*,
std::string, std::string,
blob, blob_type_t,
timestamp, timestamp,
date_type_t, date_type_t,
time_type_t, time_type_t,

View File

@ -14,7 +14,7 @@ template<typename Type>
size_t determine_size(const Type &/*val*/) { return 0; } size_t determine_size(const Type &/*val*/) { return 0; }
size_t determine_size(const std::string &val); size_t determine_size(const std::string &val);
size_t determine_size(const char *val); size_t determine_size(const char *val);
size_t determine_size(const blob &val); size_t determine_size(const blob_type_t &val);
} }

View File

@ -123,11 +123,11 @@ void data_type_traits<std::string>::bind_value(attribute_writer &binder, const s
binder.write_value(index, value, size); binder.write_value(index, value, size);
} }
void data_type_traits<blob>::read_value(attribute_reader &reader, const char *id, const size_t index, utils::blob &value, const size_t /*size*/) { void data_type_traits<blob_type_t>::read_value(attribute_reader &reader, const char *id, const size_t index, utils::blob_type_t &value, const size_t /*size*/) {
reader.read_value(id, index, value); reader.read_value(id, index, value);
} }
void data_type_traits<blob>::bind_value(attribute_writer &binder, const size_t index, blob &value, const size_t /*size*/) { void data_type_traits<blob_type_t>::bind_value(attribute_writer &binder, const size_t index, blob_type_t &value, const size_t /*size*/) {
binder.write_value(index, value); binder.write_value(index, value);
} }

View File

@ -4,7 +4,7 @@
#include <sstream> #include <sstream>
namespace matador::utils { namespace matador::utils {
std::string to_string(const blob& data) { std::string to_string(const blob_type_t& data) {
static constexpr char HEXITS[] = "0123456789ABCDEF"; static constexpr char HEXITS[] = "0123456789ABCDEF";
std::string str(2 * data.size(), '\0'); std::string str(2 * data.size(), '\0');

View File

@ -99,7 +99,7 @@ void initialize_by_basic_type(const basic_type type, database_type &val) {
val.emplace<timestamp>(); val.emplace<timestamp>();
break; break;
case basic_type::Blob: case basic_type::Blob:
val.emplace<blob>(); val.emplace<blob_type_t>();
break; break;
default: default:
val.emplace<nullptr_t>(); val.emplace<nullptr_t>();

View File

@ -12,7 +12,7 @@ size_t determine_size(const char *val) {
return strlen(val); return strlen(val);
} }
size_t determine_size(const blob &val) { size_t determine_size(const blob_type_t &val) {
return val.size(); return val.size();
} }
} }

View File

@ -96,7 +96,7 @@ void attribute_string_writer::write_value(size_t /*pos*/, const std::string &x,
result_ = "'" + dialect_.prepare_literal(x) + "'"; result_ = "'" + dialect_.prepare_literal(x) + "'";
} }
void attribute_string_writer::write_value(size_t /*pos*/, const utils::blob &x) { void attribute_string_writer::write_value(size_t /*pos*/, const utils::blob_type_t &x) {
// "This is a binary Data string" as binary data: // "This is a binary Data string" as binary data:
// MySQL: X'5468697320697320612062616E617279204461746120737472696E67' // MySQL: X'5468697320697320612062616E617279204461746120737472696E67'
// Postgres: '\\x5468697320697320612062616E617279204461746120737472696E67' // Postgres: '\\x5468697320697320612062616E617279204461746120737472696E67'

View File

@ -89,7 +89,7 @@ void value_extractor::write_value(size_t /*pos*/, const std::string &x, size_t /
values_.emplace_back(x); values_.emplace_back(x);
} }
void value_extractor::write_value(size_t /*pos*/, const utils::blob &x) { void value_extractor::write_value(size_t /*pos*/, const utils::blob_type_t &x) {
values_.emplace_back(x); values_.emplace_back(x);
} }

View File

@ -97,7 +97,7 @@ std::string dialect::next_placeholder(const std::vector<std::string> &bind_vars)
return placeholder_func_(bind_vars.size()); return placeholder_func_(bind_vars.size());
} }
std::string dialect::to_escaped_string(const utils::blob &value, const connection_impl *conn) const { std::string dialect::to_escaped_string(const utils::blob_type_t &value, const connection_impl *conn) const {
if (conn != nullptr) { if (conn != nullptr) {
return conn->to_escaped_string(value); return conn->to_escaped_string(value);
} }

View File

@ -60,7 +60,7 @@ TEST_CASE_METHOD(QueryFixture, "Insert and select basic datatypes", "[query][dat
"gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."; "gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.";
// matador::date date_val(15, 3, 2015); // matador::date date_val(15, 3, 2015);
// auto time_val = matador::time(2015, 3, 15, 13, 56, 23, 123); // auto time_val = matador::time(2015, 3, 15, 13, 56, 23, 123);
matador::utils::blob blob_val {1,2,3,4,5,6,7,8}; matador::utils::blob_type_t blob_val {1,2,3,4,5,6,7,8};
types t { types t {
1, 1,

View File

@ -88,7 +88,7 @@ TEST_CASE_METHOD(QueryFixture, "Test all data types for record", "[query][record
std::string varchar{"good day"}; std::string varchar{"good day"};
date_type_t md{2025, 11, 27}; date_type_t md{2025, 11, 27};
time_type_t mt{12, 34, 56}; time_type_t mt{12, 34, 56};
blob bin{0x01,0x02,0x03,0x04}; blob_type_t bin{0x01,0x02,0x03,0x04};
res = query::insert() res = query::insert()
.into("types", cols) .into("types", cols)
@ -122,7 +122,7 @@ TEST_CASE_METHOD(QueryFixture, "Test all data types for record", "[query][record
REQUIRE(md == row.at<date_type_t>("val_date")); REQUIRE(md == row.at<date_type_t>("val_date"));
const auto mtres = row.at<time_type_t>("val_time"); const auto mtres = row.at<time_type_t>("val_time");
REQUIRE(mt == row.at<time_type_t>("val_time")); REQUIRE(mt == row.at<time_type_t>("val_time"));
REQUIRE(bin == row.at<blob>("val_blob")); REQUIRE(bin == row.at<blob_type_t>("val_blob"));
} }
TEST_CASE_METHOD(QueryFixture, "Create and drop table statement", "[query][record]") TEST_CASE_METHOD(QueryFixture, "Create and drop table statement", "[query][record]")

View File

@ -84,7 +84,7 @@ TEST_CASE_METHOD(QueryFixture, "Test insert statement", "[query][statement][inse
REQUIRE((*row)->id == 1); REQUIRE((*row)->id == 1);
REQUIRE((*row)->name == "george"); REQUIRE((*row)->name == "george");
REQUIRE((*row)->age == 45); REQUIRE((*row)->age == 45);
REQUIRE((*row)->image == matador::utils::blob{1,2,3,4}); REQUIRE((*row)->image == matador::utils::blob_type_t{1,2,3,4});
} }
TEST_CASE_METHOD(QueryFixture, "Test update statement", "[query][statement][update]") { TEST_CASE_METHOD(QueryFixture, "Test update statement", "[query][statement][update]") {
@ -129,7 +129,7 @@ TEST_CASE_METHOD(QueryFixture, "Test update statement", "[query][statement][upda
REQUIRE((*row)->id == 1); REQUIRE((*row)->id == 1);
REQUIRE((*row)->name == "george"); REQUIRE((*row)->name == "george");
REQUIRE((*row)->age == 45); REQUIRE((*row)->age == 45);
REQUIRE((*row)->image == blob{1,2,3,4}); REQUIRE((*row)->image == blob_type_t{1,2,3,4});
george.age = 36; george.age = 36;
george.image = {5,6,7,8}; george.image = {5,6,7,8};
@ -154,7 +154,7 @@ TEST_CASE_METHOD(QueryFixture, "Test update statement", "[query][statement][upda
REQUIRE((*row)->id == 1); REQUIRE((*row)->id == 1);
REQUIRE((*row)->name == "george"); REQUIRE((*row)->name == "george");
REQUIRE((*row)->age == 36); REQUIRE((*row)->age == 36);
REQUIRE((*row)->image == blob{5,6,7,8}); REQUIRE((*row)->image == blob_type_t{5,6,7,8});
} }
TEST_CASE_METHOD(QueryFixture, "Test delete statement", "[query][statement][delete]") { TEST_CASE_METHOD(QueryFixture, "Test delete statement", "[query][statement][delete]") {

View File

@ -118,8 +118,8 @@ TEST_CASE("Test string to floating point conversion", "[convert][string][floatin
} }
TEST_CASE("Test blob to blob conversion", "[convert][blob]") { TEST_CASE("Test blob to blob conversion", "[convert][blob]") {
blob from{1, 2, 3, 4}; blob_type_t from{1, 2, 3, 4};
const auto res = to<blob>(from); const auto res = to<blob_type_t>(from);
REQUIRE(res.is_ok()); REQUIRE(res.is_ok());
REQUIRE(from == *res); REQUIRE(from == *res);

View File

@ -24,5 +24,5 @@ TEST_CASE("Test default data types", "[data_types][type]") {
REQUIRE(data_type_traits<char[]>::type(0) == basic_type::Text); REQUIRE(data_type_traits<char[]>::type(0) == basic_type::Text);
REQUIRE(data_type_traits<std::string>::type(32) == basic_type::Varchar); REQUIRE(data_type_traits<std::string>::type(32) == basic_type::Varchar);
REQUIRE(data_type_traits<std::string>::type(0) == basic_type::Text); REQUIRE(data_type_traits<std::string>::type(0) == basic_type::Text);
REQUIRE(data_type_traits<blob>::type(0) == basic_type::Blob); REQUIRE(data_type_traits<blob_type_t>::type(0) == basic_type::Blob);
} }

View File

@ -13,7 +13,7 @@ struct person {
unsigned int id{}; unsigned int id{};
std::string name; std::string name;
unsigned int age{}; unsigned int age{};
utils::blob image{}; utils::blob_type_t image{};
template<class Operator> template<class Operator>
void process(Operator &op) { void process(Operator &op) {

View File

@ -27,7 +27,7 @@ struct types
std::string varchar_ = "Erde"; std::string varchar_ = "Erde";
// matador::date date_; // matador::date date_;
// matador::time time_; // matador::time time_;
utils::blob binary_{ 1, 2, 3, 4 }; utils::blob_type_t binary_{ 1, 2, 3, 4 };
template < class Operator > template < class Operator >
void process(Operator &op) void process(Operator &op)

View File

@ -65,7 +65,7 @@ utils::result<bool, utils::error> test_connection::exists(const std::string &/*s
return utils::ok(false); return utils::ok(false);
} }
std::string test_connection::to_escaped_string(const utils::blob& value) const { std::string test_connection::to_escaped_string(const utils::blob_type_t& value) const {
return utils::to_string(value); return utils::to_string(value);
} }

View File

@ -22,7 +22,7 @@ public:
utils::result<std::vector<object::attribute>, utils::error> describe(const std::string &table) override; utils::result<std::vector<object::attribute>, utils::error> describe(const std::string &table) override;
utils::result<bool, utils::error> exists(const std::string &schema_name, const std::string &table_name) override; utils::result<bool, utils::error> exists(const std::string &schema_name, const std::string &table_name) override;
[[nodiscard]] std::string to_escaped_string( const utils::blob& value ) const override; [[nodiscard]] std::string to_escaped_string( const utils::blob_type_t& value ) const override;
private: private:
bool is_open_{false}; bool is_open_{false};

View File

@ -19,6 +19,6 @@ void test_parameter_binder::write_value(size_t /*pos*/, const char * /*x*/) {}
void test_parameter_binder::write_value(size_t /*pos*/, const char * /*x*/, size_t /*size*/) {} void test_parameter_binder::write_value(size_t /*pos*/, const char * /*x*/, size_t /*size*/) {}
void test_parameter_binder::write_value(size_t /*pos*/, const std::string &/*x*/) {} void test_parameter_binder::write_value(size_t /*pos*/, const std::string &/*x*/) {}
void test_parameter_binder::write_value(size_t /*pos*/, const std::string &/*x*/, size_t /*size*/) {} void test_parameter_binder::write_value(size_t /*pos*/, const std::string &/*x*/, size_t /*size*/) {}
void test_parameter_binder::write_value(size_t /*pos*/, const utils::blob &/*x*/) {} void test_parameter_binder::write_value(size_t /*pos*/, const utils::blob_type_t &/*x*/) {}
void test_parameter_binder::write_value(size_t /*pos*/, const utils::value &/*x*/, size_t /*size*/) {} void test_parameter_binder::write_value(size_t /*pos*/, const utils::value &/*x*/, size_t /*size*/) {}
} }

View File

@ -25,7 +25,7 @@ public:
void write_value(size_t pos, const char *x, size_t size) override; void write_value(size_t pos, const char *x, size_t size) override;
void write_value(size_t pos, const std::string &x) override; void write_value(size_t pos, const std::string &x) override;
void write_value(size_t pos, const std::string &x, size_t size) override; void write_value(size_t pos, const std::string &x, size_t size) override;
void write_value(size_t pos, const utils::blob &x) override; void write_value(size_t pos, const utils::blob_type_t &x) override;
void write_value(size_t pos, const utils::value &x, size_t size) override; void write_value(size_t pos, const utils::value &x, size_t size) override;
}; };

View File

@ -64,10 +64,16 @@ void test_result_reader::read_value(const char * /*id*/, const size_t /*index*/,
value = 2.14159265358979323846; value = 2.14159265358979323846;
} }
void test_result_reader::read_value(const char * /*id*/, const size_t /*index*/, matador::time &/*value*/) { void test_result_reader::read_value(const char * /*id*/, const size_t /*index*/, utils::date_type_t &value) {
value = {2021, 10, 27};
} }
void test_result_reader::read_value(const char * /*id*/, const size_t /*index*/, matador::date &/*value*/) { void test_result_reader::read_value(const char * /*id*/, const size_t /*index*/, utils::time_type_t &value) {
value = {12, 34, 56, 123456};
}
void test_result_reader::read_value(const char *id, size_t index, utils::timestamp &value) {
value = utils::timestamp();
} }
void test_result_reader::read_value(const char * /*id*/, const size_t /*index*/, char * /*value*/, const size_t /*size*/) { void test_result_reader::read_value(const char * /*id*/, const size_t /*index*/, char * /*value*/, const size_t /*size*/) {
@ -81,7 +87,7 @@ void test_result_reader::read_value(const char * /*id*/, const size_t /*index*/,
value = "Hello world"; value = "Hello world";
} }
void test_result_reader::read_value(const char * /*id*/, const size_t /*index*/, utils::blob &value) { void test_result_reader::read_value(const char * /*id*/, const size_t /*index*/, utils::blob_type_t &value) {
value = {'b', 'l', 'o', 'b'}; value = {'b', 'l', 'o', 'b'};
} }

View File

@ -21,12 +21,13 @@ public:
void read_value(const char *, size_t, bool &) override {} void read_value(const char *, size_t, bool &) override {}
void read_value(const char *, size_t, float &) override {} void read_value(const char *, size_t, float &) override {}
void read_value(const char *, size_t, double &) override {} void read_value(const char *, size_t, double &) override {}
void read_value(const char *, size_t, time &) override {} void read_value(const char *, size_t, utils::date_type_t &) override {}
void read_value(const char *, size_t, date &) override {} void read_value(const char *, size_t, utils::time_type_t &) override {}
void read_value(const char *, size_t, utils::timestamp &) override {}
void read_value(const char *, size_t, char *, size_t) override {} void read_value(const char *, size_t, char *, size_t) override {}
void read_value(const char *, size_t, std::string &) override {} void read_value(const char *, size_t, std::string &) override {}
void read_value(const char *, size_t, std::string &, size_t) override {} void read_value(const char *, size_t, std::string &, size_t) override {}
void read_value(const char *, size_t, utils::blob &) override {} void read_value(const char *, size_t, utils::blob_type_t &) override {}
void read_value(const char *, size_t, utils::value &, size_t) override {} void read_value(const char *, size_t, utils::value &, size_t) override {}
}; };
@ -51,12 +52,13 @@ public:
void read_value(const char *id, size_t index, bool &value) override; void read_value(const char *id, size_t index, bool &value) override;
void read_value(const char *id, size_t index, float &value) override; void read_value(const char *id, size_t index, float &value) override;
void read_value(const char *id, size_t index, double &value) override; void read_value(const char *id, size_t index, double &value) override;
void read_value(const char *id, size_t index, matador::time &value) override; void read_value(const char *id, size_t index, utils::date_type_t &value) override;
void read_value(const char *id, size_t index, matador::date &value) override; void read_value(const char *id, size_t index, utils::time_type_t &value) override;
void read_value(const char *id, size_t index, utils::timestamp &value) override;
void read_value(const char *id, size_t index, char *value, size_t size) override; void read_value(const char *id, size_t index, char *value, size_t size) override;
void read_value(const char *id, size_t index, std::string &value) override; void read_value(const char *id, size_t index, std::string &value) override;
void read_value(const char *id, size_t index, std::string &value, size_t size) override; void read_value(const char *id, size_t index, std::string &value, size_t size) override;
void read_value(const char *id, size_t index, utils::blob &value) override; void read_value(const char *id, size_t index, utils::blob_type_t &value) override;
void read_value(const char *id, size_t index, utils::value &val, size_t size) override; void read_value(const char *id, size_t index, utils::value &val, size_t size) override;
protected: protected:

View File

@ -234,7 +234,7 @@ TEST_CASE_METHOD(QueryFixture, "Test create, insert and select a blob column", "
result = query::insert() result = query::insert()
.into("person", {"id", "name", "data"}) .into("person", {"id", "name", "data"})
.values({7U, "george", blob{1, 'A', 3, 4}}) .values({7U, "george", blob_type_t{1, 'A', 3, 4}})
.str(*db); .str(*db);
REQUIRE(result == R"(INSERT INTO "person" ("id", "name", "data") VALUES (7, 'george', X'01410304'))"); REQUIRE(result == R"(INSERT INTO "person" ("id", "name", "data") VALUES (7, 'george', X'01410304'))");

View File

@ -37,7 +37,7 @@ TEST_CASE("Test field", "[field]") {
REQUIRE(bool_val.has_value()); REQUIRE(bool_val.has_value());
REQUIRE(bool_val.value()); REQUIRE(bool_val.value());
f = sql::field("name", utils::blob{ 7,8,6,5,4,3 }, utils::constraints::None, 0, 1); f = sql::field("name", utils::blob_type_t{ 7,8,6,5,4,3 }, utils::constraints::None, 0, 1);
REQUIRE(f.index() == 1); REQUIRE(f.index() == 1);
REQUIRE(!f.is_null()); REQUIRE(!f.is_null());
REQUIRE(!f.is_integer()); REQUIRE(!f.is_integer());
@ -46,9 +46,9 @@ TEST_CASE("Test field", "[field]") {
REQUIRE(!f.is_bool()); REQUIRE(!f.is_bool());
REQUIRE(!f.is_string()); REQUIRE(!f.is_string());
auto blob_val = f.as<utils::blob>(); auto blob_val = f.as<utils::blob_type_t>();
REQUIRE(blob_val.has_value()); REQUIRE(blob_val.has_value());
REQUIRE(blob_val.value() == utils::blob{ 7,8,6,5,4,3 }); REQUIRE(blob_val.value() == utils::blob_type_t{ 7,8,6,5,4,3 });
REQUIRE(!f.as<std::string>().has_value()); REQUIRE(!f.as<std::string>().has_value());
} }