From b5bc00cd10475d831de1952086c08fcbcb57dbb6 Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Wed, 13 Jul 2011 10:04:57 +0200 Subject: Add support for DATE, TIME and TIMESTAMP PostgreSQL types --- odb/relational/pgsql/common.cxx | 11 +++++++++-- odb/relational/pgsql/source.cxx | 40 ++++++++++++++++++++++------------------ 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/odb/relational/pgsql/common.cxx b/odb/relational/pgsql/common.cxx index 4a22d46..c5e3c9f 100644 --- a/odb/relational/pgsql/common.cxx +++ b/odb/relational/pgsql/common.cxx @@ -174,6 +174,13 @@ namespace relational "float", "double" }; + + const char* date_time_types[] = + { + "int", + "long long", + "long long" + }; } member_image_type:: @@ -217,9 +224,9 @@ namespace relational } void member_image_type:: - traverse_date_time (member_info&) + traverse_date_time (member_info& mi) { - type_ = "details::buffer"; + type_ = date_time_types[mi.st->type - sql_type::DATE]; } void member_image_type:: diff --git a/odb/relational/pgsql/source.cxx b/odb/relational/pgsql/source.cxx index 89531f3..6aaf930 100644 --- a/odb/relational/pgsql/source.cxx +++ b/odb/relational/pgsql/source.cxx @@ -73,6 +73,13 @@ namespace relational "pgsql::bind::bytea", // BYTEA }; + const char* date_time_buffer_types[] = + { + "pgsql::bind::date", + "pgsql::bind::time", + "pgsql::bind::timestamp" + }; + const char* oids[] = { "pgsql::bool_oid", // BOOLEAN @@ -93,13 +100,6 @@ namespace relational "pgsql::varbit_oid", // VARBIT "pgsql::uuid_oid" // UUID }; - - // @@ Complete once date-time format is known. - // - - // const char* date_time_buffer_types[] = - // { - // }; } struct statement_oids: object_columns_base, context @@ -208,10 +208,12 @@ namespace relational } virtual void - traverse_date_time (member_info&) + traverse_date_time (member_info& mi) { - // @@ Complete once date-time format is known. - // + os << b << ".type = " << + date_time_buffer_types[mi.st->type - sql_type::DATE] << ";" + << b << ".buffer = &" << arg << "." << mi.var << "value;" + << b << ".is_null = &" << arg << "." << mi.var << "null;"; } virtual void @@ -339,8 +341,8 @@ namespace relational virtual void traverse_date_time (member_info&) { - // @@ Complete once date-time format is known. - // + os << e << " = 0;" + << endl; } virtual void @@ -551,10 +553,10 @@ namespace relational } virtual void - traverse_date_time (member_info&) + traverse_date_time (member_info& mi) { - // @@ Complete once date-time format is known. - // + os << traits << "::set_image (" << endl + << "i." << mi.var << "value, is_null, " << member << ");"; } virtual void @@ -767,10 +769,12 @@ namespace relational } virtual void - traverse_date_time (member_info&) + traverse_date_time (member_info& mi) { - // @@ Complete once date-time format is known. - // + os << traits << "::set_value (" << endl + << member << ", i." << mi.var << "value, " << + "i." << mi.var << "null);" + << endl; } virtual void -- cgit v1.1