List:MySQL++« Previous MessageNext Message »
From:Chris Frey Date:December 15 2004 8:43pm
Subject:escaping, quoting, and nulls
View as plain text  
Hi folks,

I'm trying to grok the features in mysql++.  Specifically, I'm really interested
in how to handle escaping, quoting, and nulls, in a seamless manner.

I know there are macros to make "table-like" structures, but I'm not ready
to incorporate that into my project.  If someone convinces me, I'm not
against switching, but it should be good. :-)

To give you an idea of what I'm after, I have classes for various ID's
in my system.  These IDs relate to numeric fields in my tables, usually
auto_increment, sometimes they are just references to other places and
may be NULL.

To allow for future flexibility, I have a set of ID classes that represent
them as int's, and some that represent them as std::string's.

I want to be able to do something like this, and have it automatically
escape/quote/null for me:

	Query q = con.query();

and yet I don't necessarily want the data escaped when I do:

	std::cerr << "The ID is: " << UserID;

Currently, I don't believe the mysql++ infrastructure supports this, but I think
it could, since it has its own SQLQuery object that does << work.

Currently I'm kluding things with a custom manipulator like:

	q << "SELECT * FROM USERS WHERE USERID = " << sqlquote(UserID);

Which handles various types appropriately.  This doesn't seem satisfactory
to me since the quoting knowledge is at the query level, and not tied
with the object that knows itself better anyway.

I of course need similar support for other types.

Anyone else run into these issues and desire a better solution?  Is clean
support for this kind of stuff worth building for mysql++ 2.x?  Does mysql++
already support this cleanly and I just can't get my head around it? :-)

- Chris

escaping, quoting, and nullsChris Frey15 Dec
  • Re: escaping, quoting, and nullsWarren Young16 Dec