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/query.hxx | |
parent | beb52e1cbd129549a4c70c44d567c891f656359f (diff) |
Add support for DATE, TIME and TIMESTAMP SQL types
Diffstat (limited to 'odb/pgsql/query.hxx')
-rw-r--r-- | odb/pgsql/query.hxx | 186 |
1 files changed, 102 insertions, 84 deletions
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 <typename T> - // struct query_param_impl<T, id_date>: query_param - // { - // query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} - // query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);} + template <typename T> + struct query_param_impl<T, id_date>: query_param + { + query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} + query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);} - // virtual bool - // init () - // { - // init (*static_cast<const T*> (value_)); - // return false; - // } + virtual bool + init () + { + init (*static_cast<const T*> (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<T, id_date>::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<T, id_date>::set_image (image_, dummy, v); + } + + private: + int image_; + }; - // @@ TIME + // TIME // - // template <typename T> - // struct query_param_impl<T, id_time>: query_param - // { - // query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} - // query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);} + template <typename T> + struct query_param_impl<T, id_time>: query_param + { + query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} + query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);} - // virtual bool - // init () - // { - // init (*static_cast<const T*> (value_)); - // return false; - // } + virtual bool + init () + { + init (*static_cast<const T*> (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<T, id_time>::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<T, id_time>::set_image (image_, dummy, v); + } + + private: + long long image_; + }; - // @@ TIMESTAMP + // TIMESTAMP // - // template <typename T> - // struct query_param_impl<T, id_timestamp>: query_param - // { - // query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} - // query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);} + template <typename T> + struct query_param_impl<T, id_timestamp>: query_param + { + query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} + query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);} - // virtual bool - // init () - // { - // init (*static_cast<const T*> (value_)); - // return false; - // } + virtual bool + init () + { + init (*static_cast<const T*> (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<T, id_timestamp>::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<T, id_timestamp>::set_image (image_, dummy, v); + } + + private: + long long image_; + }; // STRING // |