mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-10 07:02:11 -06:00
Add support for std::array blobs
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user