diff options
author | Constantin Michael <constantin@codesynthesis.com> | 2011-07-13 10:03:09 +0200 |
---|---|---|
committer | Constantin Michael <constantin@codesynthesis.com> | 2011-07-13 10:03:09 +0200 |
commit | e607b4dfb03f17e073725013df12a11547fc6a54 (patch) | |
tree | 2b74ffb991b763a87fc9a26b6cca7b5f3d64db8d /odb/pgsql/statement.cxx | |
parent | beb52e1cbd129549a4c70c44d567c891f656359f (diff) |
Add support for DATE, TIME and TIMESTAMP SQL types
Diffstat (limited to 'odb/pgsql/statement.cxx')
-rw-r--r-- | odb/pgsql/statement.cxx | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/odb/pgsql/statement.cxx b/odb/pgsql/statement.cxx index e9497df..cb49332 100644 --- a/odb/pgsql/statement.cxx +++ b/odb/pgsql/statement.cxx @@ -89,7 +89,7 @@ namespace odb n.values[i] = reinterpret_cast<char*> (current_bind.buffer); - // Use text format for numeric/decimal types and binary format + // Use text format for numeric types and binary format // for all others. // if (current_bind.type == bind::numeric) @@ -132,6 +132,17 @@ namespace odb l = sizeof (double); break; } + case bind::date: + { + l = sizeof (int); + break; + } + case bind::time: + case bind::timestamp: + { + l = sizeof (long long); + break; + } case bind::uuid: { // UUID is a 16-byte sequence. @@ -195,7 +206,9 @@ namespace odb case bind::boolean: { *static_cast<bool*> (b.buffer) = - reinterpret_cast<const bool*> (v); + *reinterpret_cast<const bool*> (v); + + break; } case bind::smallint: { @@ -206,8 +219,7 @@ namespace odb } case bind::integer: { - *static_cast<int*> (b.buffer) = - *reinterpret_cast<const int*> (v); + *static_cast<int*> (b.buffer) = *reinterpret_cast<const int*> (v); break; } @@ -232,6 +244,20 @@ namespace odb break; } + case bind::date: + { + *static_cast<int*> (b.buffer) = *reinterpret_cast<const int*> (v); + + break; + } + case bind::time: + case bind::timestamp: + { + *static_cast<long long*> (b.buffer) = + *reinterpret_cast<const long long*> (v); + + break; + } case bind::numeric: case bind::text: case bind::bytea: @@ -256,6 +282,7 @@ namespace odb case bind::uuid: { memcpy (b.buffer, v, 16); + break; } } |