From 9c275a93cec797a021571ba8545906e0b4ffbfbc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 5 Sep 2011 10:20:47 +0200 Subject: Support for views; native part --- odb/database.txx | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'odb/database.txx') diff --git a/odb/database.txx b/odb/database.txx index e60d7a8..8117997 100644 --- a/odb/database.txx +++ b/odb/database.txx @@ -223,19 +223,43 @@ namespace odb } template - result database:: - query (const odb::query::object_type>& q, - bool cache) + struct database::query_ { // T can be const T while object_type will always be T. // typedef typename odb::object_traits::object_type object_type; typedef odb::object_traits object_traits; + static result + call (database& db, const odb::query& q) + { + return object_traits::template query (db, q); + } + }; + + template + struct database::query_ + { + // Const views are not supported. + // + typedef odb::view_traits view_traits; + + static result + call (database& db, const odb::query& q) + { + return view_traits::query (db, q); + } + }; + + template + result database:: + query (const odb::query::result>& q, + bool cache) + { if (!transaction::has_current ()) throw not_in_transaction (); - result r (object_traits::template query (*this, q)); + result r (query_::kind>::call (*this, q)); if (cache) r.cache (); -- cgit v1.1