There is a bug in the user manual:
4.1 Setting up template queries
query << "select (%2:field1, %3:field2) from stock where %1:wheref =
%q0:what";
-> should be
query << "select (%2:field1, %3:field2) from stock where %1:wheref =
%0q:what";
...
%(modifier)##(:name)(:) -> should be %##(modifier)(:name)(:)
I think I have also found a bug in the source using template queries:
In my opinion the template queries have the advantage, that a query has
to be parsed only once. Thus following example should work:
Result res;
Query q << "select name, zip, state, country from person where name like
%0q:name";
q.parse();
q.def["name"]="a%";
res=q.store();
// res holds all date of persons with name starting with a
// q.store() generates: select name, zip, state, country from person
where name like 'a%'
q.def["name"]="b%";
res=q.store();
// res should hold all date of persons with name starting with b
// q.store() generates: select name, zip, state, country from person
where name like b%
// a SQL-Error is produced
---------------------------------
patch_sql_string.h:
assigning a new value to a template parameter needs to change the
attribute processed to false
patch_sql_query.cpp:
SQLQuery::parse() -> using isalnum() to search for the template
parameter name
patch_docu:
clean up docu
--
Jürgen MF Gleiss
GLEISS & LEEB GESELLSCHAFT M. B. H.
H. Schneidmadlstraße 15, 1.02
3107 St. Pölten
Tel.: +43 (0)676 / 6669644
Fax: +43 (0)2742 / 9001 - 7124
eMail: office@stripped
--- mysql++-1.7.40/lib/sql_string.h 2005-05-26 11:09:32.000000000 +0200
+++ mysql++-1.7.40_jg/lib/sql_string.h 2005-08-13 09:33:59.440083264 +0200
@@ -116,6 +116,7 @@
SQLString& operator =(const char* str)
{
std::string::operator =(str);
+ processed=false;
return *this;
}
@@ -123,6 +124,7 @@
SQLString& operator =(const std::string& str)
{
std::string::operator =(str);
+ processed=false;
return *this;
}
};
--- mysql++-1.7.40/lib/sql_query.cpp 2005-05-26 08:39:22.000000000 +0200
+++ mysql++-1.7.40_jg/lib/sql_query.cpp 2005-08-13 10:00:19.582865048 +0200
@@ -220,8 +220,7 @@
if (*s == ':') {
s++;
- for ( /* */ ; (*s >= 'A' && *s <= 'Z') ||
- *s == '_' || (*s >= 'a' && *s <= 'z'); s++) {
+ for ( /* */ ; isalnum(*s) || *s == '_' ; s++) {
name += *s;
}
--- mysql++-1.7.40/doc/userman/userman.xml 2005-05-26 15:28:32.000000000 +0200
+++ mysql++-1.7.40_jg/doc/userman/userman.xml 2005-08-13 09:56:53.000000000 +0200
@@ -1793,7 +1793,7 @@
<para>The format of the placeholder is:</para>
<programlisting>
- %(modifier)##(:name)(:)</programlisting>
+ %##(modifier)(:name)(:)</programlisting>
<para>Where Modifier can be any one of the following:</para>
@@ -1888,7 +1888,7 @@
numeric order...</para>
<programlisting>
- select (%0:field1, %1:field2) from stock where %2:wheref =
%q3:what</programlisting>
+ select (%0:field1, %1:field2) from stock where %2:wheref =
%3q:what</programlisting>
<para>...will become apparent shortly.</para>
</sect2>