Author: wyoung
Date: Thu Nov 29 18:33:15 2007
New Revision: 1932

URL: http://svn.gna.org/viewcvs/mysqlpp?rev=1932&view=rev
Log:
Removed 'r' and 'R' modifiers for template query parameters.  They were
"force quoting" variants of 'q' and 'Q', which bespoke a kind of
weakness of our convictions: they could only be useful if SQLTypeAdapter
and String weren't keeping type information correctly.  You can't very
well argue for style issues in generated SQL, and even if you try, we've
never had force-quoting manipulators for Query's stream interface, so
why do we have it for template queries?  It just clutters the
implementation of template queries and the documentation for same.

Modified:
    trunk/Wishlist
    trunk/doc/userman/userman.dbx
    trunk/lib/query.cpp

Modified: trunk/Wishlist
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/Wishlist?rev=1932&r1=1931&r2=1932&view=diff
==============================================================================
--- trunk/Wishlist (original)
+++ trunk/Wishlist Thu Nov 29 18:33:15 2007
@@ -75,14 +75,6 @@
       boilerplate, which leaf SSQLSes derive from.  This should in turn
       allow template functions like Query::insert<T> to become regular
       member functions, taking a reference to the SSQLS base class.
-
-    o Either add quote_force and similar manipulators, or remove the
-      'r' and 'R' modifiers in template queries.  As it stands, you
-      can't force Query streams to quote or escape something if MySQL++
-      knows it's never required in SQL, but these modifiers let you
-      do it for parameters in template queries.  Pick one behavior,
-      and change the footnote about this from the quoting and escaping
-      section of the userman.
 
     o Fold Query::preview(void) into str(), and rename all of the
       multiple-argument forms of preview() to str().

Modified: trunk/doc/userman/userman.dbx
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/doc/userman/userman.dbx?rev=1932&r1=1931&r2=1932&view=diff
==============================================================================
--- trunk/doc/userman/userman.dbx (original)
+++ trunk/doc/userman/userman.dbx Thu Nov 29 18:33:15 2007
@@ -1455,37 +1455,26 @@
                 <entry><emphasis role="bold">%</emphasis></entry>
                 <entry>Print an actual "%"</entry>
             </row>
+
             <row>
                 <entry><emphasis role="bold">""</emphasis></entry>
                 <entry>Don't quote or escape no matter what.</entry>
             </row>
+
             <row>
                 <entry><emphasis role="bold">q</emphasis></entry>
-                <entry>This will quote and escape
-                the item using the MySQL C API
-                function <ulink url="mysql-escape-string"
-                type="mysqlapi"/> if it is a string or char *,
-                or another MySQL-specific type
-                that needs to be quoted.</entry>
+                <entry>This will escape the item using the MySQL
+                C API function <ulink url="mysql-escape-string"
+                type="mysqlapi"/> and add single quotes around it
+                as necessary, depending on the type of the value
+                you use.</entry>
             </row>
+
             <row>
                 <entry><emphasis role="bold">Q</emphasis></entry>
-                <entry>Quote but don't escape
-                based on the same rules as for 'q'. This
-                can save a bit of processing time if you
-                know the strings will never need
-                quoting</entry>
-            </row>
-            <row>
-                <entry><emphasis role="bold">r</emphasis></entry>
-                <entry>Always quote and escape
-                even if it is a number.</entry>
-            </row>
-            <row>
-                <entry><emphasis role="bold">R</emphasis></entry>
-                <entry>Always quote but
-                don't escape even if it is
-                a number.</entry>
+                <entry>Quote but don't escape based on the same rules
+                as for 'q'. This can save a bit of processing time
+                if you know the strings will never need quoting</entry>
             </row>
         </tbody>
         </tgroup>
@@ -1582,8 +1571,8 @@
         refer to the parameters either by position or by name:</para>
 
         <programlisting>
-query.def[1] = "item";
-query.def["wheref"] = "item";</programlisting>
+query.template_defaults[1] = "item";
+query.template_defaults["wheref"] = "item";</programlisting>
 
         <para>Both do the same thing.</para>
 
@@ -1604,8 +1593,8 @@
         less often than other parameters. For example:</para>
 
         <programlisting>
-query.def["field1"] = "item"; 
-query.def["field2"] = "price"; 
+query.template_defaults["field1"] = "item"; 
+query.template_defaults["field2"] = "price"; 
 Result res1 = query.store("Hamburger Buns", "item"); 
 Result res2 = query.store(1.25, "price"); </programlisting>
 
@@ -1625,10 +1614,10 @@
         way to set all of the template parameters in a query:</para>
 
         <programlisting>
-query.def["what"] = "Hamburger Buns";
-query.def["wheref"] = "item";
-query.def["field1"] = "item"; 
-query.def["field2"] = "price"; 
+query.template_defaults["what"] = "Hamburger Buns";
+query.template_defaults["wheref"] = "item";
+query.template_defaults["field1"] = "item"; 
+query.template_defaults["field2"] = "price"; 
 Result res1 = query.store();</programlisting>
 
         <para>This can work, but it is <emphasis>not designed
@@ -1654,8 +1643,8 @@
         <methodname>BadParamCount::what()</methodname>, like so:</para>
 
         <programlisting>
-query.def["field1"] = "item"; 
-query.def["field2"] = "price"; 
+query.template_defaults["field1"] = "item"; 
+query.template_defaults["field2"] = "price"; 
 Result res = query.store(1.25); </programlisting>
 
         <para>This would throw <classname>BadParamCount</classname>

Modified: trunk/lib/query.cpp
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/query.cpp?rev=1932&r1=1931&r2=1932&view=diff
==============================================================================
--- trunk/lib/query.cpp (original)
+++ trunk/lib/query.cpp Thu Nov 29 18:33:15 2007
@@ -267,7 +267,7 @@
 
                                // Look for option character following position 
value.
                                char option = ' ';
-                               if (*s == 'q' || *s == 'Q' || *s == 'r' || *s 
== 'R') {
+                               if (*s == 'q' || *s == 'Q') {
                                        option = *s++;
                                }
 
@@ -328,13 +328,10 @@
                return &S;
        }
 
-       if (option == 'r' || option == 'q') {
-               bool escape_q = (option == 'r') || (option == 'q' && 
S.escape_q());
-               bool quote_q = (option == 'r') || (option == 'q' && 
S.quote_q());
-
-               std::string temp(quote_q ? "'" : "", quote_q ? 1 : 0);
-
-               if (escape_q) {
+       if (option == 'q') {
+               std::string temp(S.quote_q() ? "'" : "", S.quote_q() ? 1 : 0);
+
+               if (S.escape_q()) {
                        char *escaped = new char[S.size() * 2 + 1];
                        size_t len = mysql_real_escape_string(&conn_->mysql_, 
escaped,
                                        S.data(), static_cast<unsigned 
long>(S.size()));
@@ -345,7 +342,7 @@
                        temp.append(S.data(), S.length());
                }
 
-               if (quote_q) temp.append("'", 1);
+               if (S.quote_q()) temp.append("'", 1);
 
                SQLTypeAdapter* ss = new SQLTypeAdapter(temp);
 
@@ -359,7 +356,7 @@
                        return ss;
                }
        }
-       else if (option == 'R' || (option == 'Q' && S.quote_q())) {
+       else if (option == 'Q' && S.quote_q()) {
                std::string temp("'", 1);
                temp.append(S.data(), S.length());
                temp.append("'", 1);


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

Reply via email to