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/query.hxx | 186 ++++++++++++++++++++++++++++------------------------ 1 file changed, 102 insertions(+), 84 deletions(-) (limited to 'odb/pgsql/query.hxx') diff --git a/odb/pgsql/query.hxx b/odb/pgsql/query.hxx index 933ecd9..879517c 100644 --- a/odb/pgsql/query.hxx +++ b/odb/pgsql/query.hxx @@ -1306,107 +1306,125 @@ namespace odb // unsigned long size_; // }; - // @@ DATE + // DATE // - // template - // struct query_param_impl: query_param - // { - // query_param_impl (ref_bind r) : query_param (&r.ref) {} - // query_param_impl (val_bind v) : query_param (0) {init (v.val);} + template + struct query_param_impl: query_param + { + query_param_impl (ref_bind r) : query_param (&r.ref) {} + query_param_impl (val_bind v) : query_param (0) {init (v.val);} - // virtual bool - // init () - // { - // init (*static_cast (value_)); - // return false; - // } + virtual bool + init () + { + init (*static_cast (value_)); + return false; + } - // virtual void - // bind (MYSQL_BIND* b) - // { - // b->buffer_type = MYSQL_TYPE_DATE; - // b->buffer = &image_; - // } + virtual void + bind (pgsql::bind* b) + { + b->type = bind::date; + b->buffer = &image_; + } - // private: - // void - // init (const T& v) - // { - // bool dummy; - // value_traits::set_image (image_, dummy, v); - // } + virtual unsigned int + oid () const + { + return date_oid; + } - // private: - // MYSQL_TIME image_; - // }; + private: + void + init (const T& v) + { + bool dummy; + value_traits::set_image (image_, dummy, v); + } + + private: + int image_; + }; - // @@ TIME + // TIME // - // template - // struct query_param_impl: query_param - // { - // query_param_impl (ref_bind r) : query_param (&r.ref) {} - // query_param_impl (val_bind v) : query_param (0) {init (v.val);} + template + struct query_param_impl: query_param + { + query_param_impl (ref_bind r) : query_param (&r.ref) {} + query_param_impl (val_bind v) : query_param (0) {init (v.val);} - // virtual bool - // init () - // { - // init (*static_cast (value_)); - // return false; - // } + virtual bool + init () + { + init (*static_cast (value_)); + return false; + } - // virtual void - // bind (MYSQL_BIND* b) - // { - // b->buffer_type = MYSQL_TYPE_TIME; - // b->buffer = &image_; - // } + virtual void + bind (pgsql::bind* b) + { + b->type = bind::time; + b->buffer = &image_; + } - // private: - // void - // init (const T& v) - // { - // bool dummy; - // value_traits::set_image (image_, dummy, v); - // } + virtual unsigned int + oid () const + { + return time_oid; + } - // private: - // MYSQL_TIME image_; - // }; + private: + void + init (const T& v) + { + bool dummy; + value_traits::set_image (image_, dummy, v); + } + + private: + long long image_; + }; - // @@ TIMESTAMP + // TIMESTAMP // - // template - // struct query_param_impl: query_param - // { - // query_param_impl (ref_bind r) : query_param (&r.ref) {} - // query_param_impl (val_bind v) : query_param (0) {init (v.val);} + template + struct query_param_impl: query_param + { + query_param_impl (ref_bind r) : query_param (&r.ref) {} + query_param_impl (val_bind v) : query_param (0) {init (v.val);} - // virtual bool - // init () - // { - // init (*static_cast (value_)); - // return false; - // } + virtual bool + init () + { + init (*static_cast (value_)); + return false; + } - // virtual void - // bind (MYSQL_BIND* b) - // { - // b->buffer_type = MYSQL_TYPE_TIMESTAMP; - // b->buffer = &image_; - // } + virtual void + bind (pgsql::bind* b) + { + b->type = bind::timestamp; + b->buffer = &image_; + } - // private: - // void - // init (const T& v) - // { - // bool dummy; - // value_traits::set_image (image_, dummy, v); - // } + virtual unsigned int + oid () const + { + return timestamp_oid; + } - // private: - // MYSQL_TIME image_; - // }; + private: + void + init (const T& v) + { + bool dummy; + value_traits::set_image (image_, dummy, v); + } + + private: + long long image_; + }; // STRING // -- cgit v1.1