Add support for std::array blobs

This commit is contained in:
Philippe Daouadi
2018-03-09 18:16:29 +01:00
committed by rbock
parent 7b16f03aa0
commit 1b12fddb7a
3 changed files with 16 additions and 0 deletions

View File

@@ -52,6 +52,11 @@ namespace sqlpp
{
}
template <std::size_t N>
blob_operand(const std::array<uint8_t, N>& t) : _t(t.begin(), t.end())
{
}
blob_operand(const blob_operand&) = default;
blob_operand(blob_operand&&) = default;
blob_operand& operator=(const blob_operand&) = default;

View File

@@ -41,5 +41,11 @@ namespace sqlpp
{
using type = blob_operand;
};
template <std::size_t N>
struct wrap_operand<std::array<std::uint8_t, N>, void>
{
using type = blob_operand;
};
}
#endif

View File

@@ -28,6 +28,7 @@
#include <sqlpp11/sqlpp11.h>
#include <iostream>
#include <array>
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<uint8_t, 8> 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());