Author: wyoung
Date: Fri Mar 16 00:46:41 2007
New Revision: 1443

URL: http://svn.gna.org/viewcvs/mysqlpp?rev=1443&view=rev
Log:
Fixed single-parameter template query handling.  Was taking the
parameter as the entire query string, which of course annoyed MySQL.

Modified:
    trunk/lib/query.cpp

Modified: trunk/lib/query.cpp
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/query.cpp?rev=1443&r1=1442&r2=1443&view=diff
==============================================================================
--- trunk/lib/query.cpp (original)
+++ trunk/lib/query.cpp Fri Mar 16 00:46:41 2007
@@ -108,11 +108,12 @@
 ResNSel
 Query::execute(const SQLString& str)
 {
-       if ((def.size() == 1) && !def.processing_) {
-               // Take str to be a lone parameter for a template query.  The
-               // auto-reset flag is required because we'll end up back in this
-               // function once the query string is built, but we need to take
-               // the 'else' path to avoid an infinite loop.
+       if (!parse_elems_.empty() && !def.processing_) {
+               // We're a template query and we haven't gone through this path
+               // before, so take str to be a lone parameter for the query.
+               // We will come back through this function with a completed
+               // query, but the processing_ flag will be reset, allowing us to
+               // take the 'else' path, avoiding an infinite loop.
                AutoFlag<> af(def.processing_);
                return execute(SQLQueryParms() << str);
        }
@@ -406,11 +407,12 @@
 Result 
 Query::store(const SQLString& str)
 {
-       if ((def.size() == 1) && !def.processing_) {
-               // Take str to be a lone parameter for a template query.  The
-               // auto-reset flag is required because we'll end up back in this
-               // function once the query string is built, but we need to take
-               // the 'else' path to avoid an infinite loop.
+       if (!parse_elems_.empty() && !def.processing_) {
+               // We're a template query and we haven't gone through this path
+               // before, so take str to be a lone parameter for the query.
+               // We will come back through this function with a completed
+               // query, but the processing_ flag will be reset, allowing us to
+               // take the 'else' path, avoiding an infinite loop.
                AutoFlag<> af(def.processing_);
                return store(SQLQueryParms() << str);
        }
@@ -576,11 +578,12 @@
 ResUse
 Query::use(const SQLString& str)
 {
-       if ((def.size() == 1) && !def.processing_) {
-               // Take str to be a lone parameter for a template query.  The
-               // auto-reset flag is required because we'll end up back in this
-               // function once the query string is built, but we need to take
-               // the 'else' path to avoid an infinite loop.
+       if (!parse_elems_.empty() && !def.processing_) {
+               // We're a template query and we haven't gone through this path
+               // before, so take str to be a lone parameter for the query.
+               // We will come back through this function with a completed
+               // query, but the processing_ flag will be reset, allowing us to
+               // take the 'else' path, avoiding an infinite loop.
                AutoFlag<> af(def.processing_);
                return use(SQLQueryParms() << str);
        }


_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits

Reply via email to