aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-12-03 13:12:20 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-12-03 13:12:20 +0200
commitb469b436b9b1b1abe3efbfbb76341fc90ab1a453 (patch)
tree522a2d7efffcaf872e63f4086a03a1485c57d26e
parent2658e8e14e24a2d9bb57bf82c96421eb4d7a9d71 (diff)
Add support for executing common query using static interface
-rw-r--r--odb/oracle/connection.hxx6
-rw-r--r--odb/oracle/connection.ixx11
-rw-r--r--odb/oracle/database.hxx18
-rw-r--r--odb/oracle/database.ixx51
4 files changed, 69 insertions, 17 deletions
diff --git a/odb/oracle/connection.hxx b/odb/oracle/connection.hxx
index d6fb443..cf72b26 100644
--- a/odb/oracle/connection.hxx
+++ b/odb/oracle/connection.hxx
@@ -73,7 +73,11 @@ namespace odb
template <typename T>
prepared_query<T>
- prepare_query (const char* name, const query<T>&);
+ prepare_query (const char* name, const oracle::query_base&);
+
+ template <typename T>
+ prepared_query<T>
+ prepare_query (const char* name, const odb::query_base&);
// SQL statement tracing.
//
diff --git a/odb/oracle/connection.ixx b/odb/oracle/connection.ixx
index 9dcc818..2eb23fe 100644
--- a/odb/oracle/connection.ixx
+++ b/odb/oracle/connection.ixx
@@ -22,9 +22,18 @@ namespace odb
template <typename T>
inline prepared_query<T> connection::
- prepare_query (const char* n, const query<T>& q)
+ prepare_query (const char* n, const oracle::query_base& q)
{
return query_<T, id_oracle>::call (*this, n, q);
}
+
+ template <typename T>
+ inline prepared_query<T> connection::
+ prepare_query (const char* n, const odb::query_base& q)
+ {
+ // Translate to native query.
+ //
+ return prepare_query<T> (n, oracle::query_base (q));
+ }
}
}
diff --git a/odb/oracle/database.hxx b/odb/oracle/database.hxx
index c03ce49..ae0dc38 100644
--- a/odb/oracle/database.hxx
+++ b/odb/oracle/database.hxx
@@ -248,7 +248,11 @@ namespace odb
template <typename T>
unsigned long long
- erase_query (const oracle::query<T>&);
+ erase_query (const oracle::query_base&);
+
+ template <typename T>
+ unsigned long long
+ erase_query (const odb::query_base&);
// Query API.
//
@@ -266,7 +270,11 @@ namespace odb
template <typename T>
result<T>
- query (const oracle::query<T>&);
+ query (const oracle::query_base&);
+
+ template <typename T>
+ result<T>
+ query (const odb::query_base&);
// Query preparation.
//
@@ -280,7 +288,11 @@ namespace odb
template <typename T>
prepared_query<T>
- prepare_query (const char* name, const oracle::query<T>&);
+ prepare_query (const char* name, const oracle::query_base&);
+
+ template <typename T>
+ prepared_query<T>
+ prepare_query (const char* name, const odb::query_base&);
// Transactions.
//
diff --git a/odb/oracle/database.ixx b/odb/oracle/database.ixx
index 38594a1..96c7731 100644
--- a/odb/oracle/database.ixx
+++ b/odb/oracle/database.ixx
@@ -335,7 +335,7 @@ namespace odb
{
// T is always object_type.
//
- return erase_query<T> (oracle::query<T> ());
+ return erase_query<T> (oracle::query_base ());
}
template <typename T>
@@ -344,7 +344,7 @@ namespace odb
{
// T is always object_type.
//
- return erase_query<T> (oracle::query<T> (q));
+ return erase_query<T> (oracle::query_base (q));
}
template <typename T>
@@ -353,12 +353,12 @@ namespace odb
{
// T is always object_type.
//
- return erase_query<T> (oracle::query<T> (q));
+ return erase_query<T> (oracle::query_base (q));
}
template <typename T>
inline unsigned long long database::
- erase_query (const oracle::query<T>& q)
+ erase_query (const oracle::query_base& q)
{
// T is always object_type.
//
@@ -366,29 +366,38 @@ namespace odb
}
template <typename T>
+ inline unsigned long long database::
+ erase_query (const odb::query_base& q)
+ {
+ // Translate to native query.
+ //
+ return erase_query<T> (oracle::query_base (q));
+ }
+
+ template <typename T>
inline result<T> database::
query ()
{
- return query<T> (oracle::query<T> ());
+ return query<T> (oracle::query_base ());
}
template <typename T>
inline result<T> database::
query (const char* q)
{
- return query<T> (oracle::query<T> (q));
+ return query<T> (oracle::query_base (q));
}
template <typename T>
inline result<T> database::
query (const std::string& q)
{
- return query<T> (oracle::query<T> (q));
+ return query<T> (oracle::query_base (q));
}
template <typename T>
inline result<T> database::
- query (const oracle::query<T>& q)
+ query (const oracle::query_base& q)
{
// T is always object_type. We also don't need to check for transaction
// here; object_traits::query () does this.
@@ -397,27 +406,45 @@ namespace odb
}
template <typename T>
+ inline result<T> database::
+ query (const odb::query_base& q)
+ {
+ // Translate to native query.
+ //
+ return query<T> (oracle::query_base (q));
+ }
+
+ template <typename T>
inline prepared_query<T> database::
prepare_query (const char* n, const char* q)
{
- return prepare_query<T> (n, oracle::query<T> (q));
+ return prepare_query<T> (n, oracle::query_base (q));
}
template <typename T>
inline prepared_query<T> database::
prepare_query (const char* n, const std::string& q)
{
- return prepare_query<T> (n, oracle::query<T> (q));
+ return prepare_query<T> (n, oracle::query_base (q));
}
template <typename T>
inline prepared_query<T> database::
- prepare_query (const char* n, const oracle::query<T>& q)
+ prepare_query (const char* n, const oracle::query_base& q)
{
// Throws if not in transaction.
//
oracle::connection& c (transaction::current ().connection ());
- return c.prepare_query (n, q);
+ return c.prepare_query<T> (n, q);
+ }
+
+ template <typename T>
+ inline prepared_query<T> database::
+ prepare_query (const char* n, const odb::query_base& q)
+ {
+ // Translate to native query.
+ //
+ return prepare_query<T> (n, oracle::query_base (q));
}
}
}