aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql/types/test.hxx6
-rw-r--r--mysql/types/traits.hxx12
2 files changed, 11 insertions, 7 deletions
diff --git a/mysql/types/test.hxx b/mysql/types/test.hxx
index 8f3c632..d950a9a 100644
--- a/mysql/types/test.hxx
+++ b/mysql/types/test.hxx
@@ -38,7 +38,7 @@ struct date_time
}
bool
- operator== (const date_time& y)
+ operator== (const date_time& y) const
{
return
negative == y.negative &&
@@ -126,7 +126,7 @@ struct buffer
}
bool
- operator== (const buffer& y)
+ operator== (const buffer& y) const
{
return size_ == y.size_ && std::memcmp (data_, y.data_, size_) == 0;
}
@@ -292,7 +292,7 @@ struct object
string_ptr null_;
bool
- operator== (const object& y)
+ operator== (const object& y) const
{
return
id_ == y.id_ &&
diff --git a/mysql/types/traits.hxx b/mysql/types/traits.hxx
index 250343a..7d42798 100644
--- a/mysql/types/traits.hxx
+++ b/mysql/types/traits.hxx
@@ -108,9 +108,14 @@ namespace odb
bool is_null)
{
if (!is_null)
- std::memcpy (&v, s, 1);
+ {
+ v.a = *s & 1;
+ v.b = (*s >> 1) & 1;
+ v.c = (*s >> 2) & 1;
+ v.d = (*s >> 3) & 1;
+ }
else
- std::memset (&v, 0, sizeof (bitfield));
+ v.a = v.b = v.c = v.d = 0;
}
static void
@@ -122,8 +127,7 @@ namespace odb
{
is_null = false;
n = 1;
- std::memcpy (s, &v, 1);
- s[0] &= 0x0F; // Clear unused bits -- MySQL is sensitive about that.
+ *s = v.a | (v.b << 1) | (v.c << 2) | (v.d << 3);
}
};