From e607b4dfb03f17e073725013df12a11547fc6a54 Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Wed, 13 Jul 2011 10:03:09 +0200 Subject: Add support for DATE, TIME and TIMESTAMP SQL types --- odb/pgsql/statement.cxx | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'odb/pgsql/statement.cxx') 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 (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 (b.buffer) = - reinterpret_cast (v); + *reinterpret_cast (v); + + break; } case bind::smallint: { @@ -206,8 +219,7 @@ namespace odb } case bind::integer: { - *static_cast (b.buffer) = - *reinterpret_cast (v); + *static_cast (b.buffer) = *reinterpret_cast (v); break; } @@ -232,6 +244,20 @@ namespace odb break; } + case bind::date: + { + *static_cast (b.buffer) = *reinterpret_cast (v); + + break; + } + case bind::time: + case bind::timestamp: + { + *static_cast (b.buffer) = + *reinterpret_cast (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; } } -- cgit v1.1