From 1b12fddb7a0fa23f9abd07bef86a7ad010568573 Mon Sep 17 00:00:00 2001 From: Philippe Daouadi Date: Fri, 9 Mar 2018 18:16:29 +0100 Subject: [PATCH] Add support for std::array blobs --- include/sqlpp11/data_types/blob/operand.h | 5 +++++ include/sqlpp11/data_types/blob/wrap_operand.h | 6 ++++++ test_serializer/Blob.cpp | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/include/sqlpp11/data_types/blob/operand.h b/include/sqlpp11/data_types/blob/operand.h index 78033d33..ad8d237b 100644 --- a/include/sqlpp11/data_types/blob/operand.h +++ b/include/sqlpp11/data_types/blob/operand.h @@ -52,6 +52,11 @@ namespace sqlpp { } + template + blob_operand(const std::array& t) : _t(t.begin(), t.end()) + { + } + blob_operand(const blob_operand&) = default; blob_operand(blob_operand&&) = default; blob_operand& operator=(const blob_operand&) = default; diff --git a/include/sqlpp11/data_types/blob/wrap_operand.h b/include/sqlpp11/data_types/blob/wrap_operand.h index 7556ccbe..ba065e21 100644 --- a/include/sqlpp11/data_types/blob/wrap_operand.h +++ b/include/sqlpp11/data_types/blob/wrap_operand.h @@ -41,5 +41,11 @@ namespace sqlpp { using type = blob_operand; }; + + template + struct wrap_operand, void> + { + using type = blob_operand; + }; } #endif diff --git a/test_serializer/Blob.cpp b/test_serializer/Blob.cpp index d9f770c5..458de030 100644 --- a/test_serializer/Blob.cpp +++ b/test_serializer/Blob.cpp @@ -28,6 +28,7 @@ #include #include +#include namespace { @@ -60,6 +61,10 @@ int Blob(int, char* []) compare(__LINE__, select(foo.book).from(foo).where(foo.book == toByteVector("john doe")), "SELECT tab_foo.book FROM tab_foo WHERE (tab_foo.book=x'6A6F686E20646F65')"); + std::array arr{{'j', 'o', 'h', 'n', ' ', 'd', 'o', 'e'}}; + compare(__LINE__, select(foo.book).from(foo).where(foo.book == arr), + "SELECT tab_foo.book FROM tab_foo WHERE (tab_foo.book=x'6A6F686E20646F65')"); + // Never compare(__LINE__, where(sqlpp::value(false)), " WHERE " + getFalse());