aboutsummaryrefslogtreecommitdiff
path: root/pgsql
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-09-11 13:55:48 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-09-11 13:55:48 +0200
commitd87a78e24d5988cfa3556707b7beffd1b0c15901 (patch)
tree32115e06a1bdade66efea1e304ba5863feaa5a21 /pgsql
parent32fcd732e2535090174142dd15b8b74fc444a9c2 (diff)
Add support for mapping std::array to BLOB and char[16] to UUID types
Diffstat (limited to 'pgsql')
-rw-r--r--pgsql/types/driver.cxx4
-rw-r--r--pgsql/types/test.hxx2
-rw-r--r--pgsql/types/traits.hxx27
3 files changed, 5 insertions, 28 deletions
diff --git a/pgsql/types/driver.cxx b/pgsql/types/driver.cxx
index 724a068..8b51cc5 100644
--- a/pgsql/types/driver.cxx
+++ b/pgsql/types/driver.cxx
@@ -61,6 +61,10 @@ main (int argc, char* argv[])
o.bit_.c = 0;
o.bit_.d = 1;
+ // 6F846D41-C89A-4E4D-B22F-56443CFA543F
+ memcpy (o.uuid_, "\x6F\x84\x6D\x41\xC8\x9A\x4E\x4D\xB2\x2F"
+ "\x56\x44\x3C\xFA\x54\x3F", 16);
+
o.enum_ = green;
// Persist.
diff --git a/pgsql/types/test.hxx b/pgsql/types/test.hxx
index 856e981..34f913f 100644
--- a/pgsql/types/test.hxx
+++ b/pgsql/types/test.hxx
@@ -150,7 +150,7 @@ struct object
// Other types.
//
#pragma db type ("UUID")
- unsigned char uuid_[16];
+ char uuid_[16];
// Test ENUM representation.
//
diff --git a/pgsql/types/traits.hxx b/pgsql/types/traits.hxx
index 0ec4079..10dcb24 100644
--- a/pgsql/types/traits.hxx
+++ b/pgsql/types/traits.hxx
@@ -130,33 +130,6 @@ namespace odb
};
template <>
- class value_traits<unsigned char[16], id_uuid>
- {
- public:
- typedef unsigned char* value_type;
- typedef details::ubuffer query_type;
- typedef unsigned char* image_type;
-
- static void
- set_value (unsigned char v[16],
- const unsigned char* i,
- bool is_null)
- {
- if (!is_null)
- std::memcpy (v, i, 16);
- else
- std::memset (v, 0, 16);
- }
-
- static void
- set_image (unsigned char* i, bool& is_null, const unsigned char v[16])
- {
- is_null = false;
- std::memcpy (i, v, 16);
- }
- };
-
- template <>
class value_traits<string_ptr, id_string>
{
public: