dbTalk Databases Forums  

Bug in Template Queries

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss Bug in Template Queries in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jürgen MF Gleiss
 
Posts: n/a

Default Bug in Template Queries - 08-13-2005 , 11:35 AM






--------------040305010307060608050306
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

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:arse() -> 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 (AT) gleiss-leeb (DOT) at



--------------040305010307060608050306
Content-Type: text/plain;
name="patch_sql_string.h_1.7.40"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="patch_sql_string.h_1.7.40"

--- 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:perator =(str);
+ processed=false;
return *this;
}

@@ -123,6 +124,7 @@
SQLString& operator =(const std::string& str)
{
std::string:perator =(str);
+ processed=false;
return *this;
}
};


--------------040305010307060608050306
Content-Type: text/plain;
name="patch_sql_query.cpp_1.7.40"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="patch_sql_query.cpp_1.7.40"

--- 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;
}



--------------040305010307060608050306
Content-Type: text/plain;
name="patch_docu_1.7.40"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="patch_docu_1.7.40"

--- 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>



--------------040305010307060608050306
Content-Type: text/plain; charset=us-ascii


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw
--------------040305010307060608050306--

Reply With Quote
  #2  
Old   
Warren Young
 
Posts: n/a

Default Re: Bug in Template Queries - 08-15-2005 , 11:03 AM






Warren Young wrote:
Quote:
No. You want isalpha() here, not is isalnum().
Nevermind. I see that the manual says different. Since it seems that
it makes no difference either way, we'll make the code match the manual.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.