
On 09/14/2010 04:12 PM, Dominique Devienne wrote:
On Tue, Sep 14, 2010 at 8:26 AM, Roland Bock<rbock@eudoxos.de> wrote:
currently I am working on a set of header files which are supposed to make the life of C++ developers easier when in comes to interacting with databases (based on SQL). Goals are:
* Stay close to SQL syntax * Do as much type checking as possible
Static type checking is always a plus. I tried going that route too, but found it a bit cumbersome (and my C++ lacking too ;) One of the problem with trying to generate queries like this is also the complexity of the SQL language itself, with nested queries, and all the various extensions and idiosyncrasies of the different SQL vendors. I've lurked on the Oracle forums for a few months, and it's open my eyes to the complexity of SQL (the Oracle dialect at least).
Yes, the code looks "interesting" so far. And I have learned quite a lot about boost.mpl in the past few weeks :-) I think I have solved (conceptually) the problem of nested queries, but the differences between the different vendors are certainly a huge problem.
The basic idea is, that given a table definition, it should be possible to * offer a lot of checks at compile time for building a query * make it hard to misinterpret the results
The few C++ libraries I've seen in this area take a less ambitious approach, and typically provide instead an easy way to pass typed C++ values as SQL bind values, and get back the records as typed tuples for examples. The SQL text must still be correct, and will be parsed and type checked only at runtime by the DB, but in practice, with unit testing, I find that it works fairly well.
Sure, but you have to do quite some testing to prevent all the possible oversights from happening. For instance, if you have a tuple of strings, it is fairly simple to mix them up. If the compiler could give you names for it, it would be harder to misuse.
A good and established library already mentioned on this list in this domain is http://soci.sourceforge.net/, which uses modern C++ and Boost.
I've seen it. It is certainly one of the best I've seen so far.
If you go that route, you'll need a way to generate the static C++ definition of the tables from existing Schemas, otherwise maintaining these to be in sync might be problematic. Then again the same applies to all the SQL text in more traditional approaches.
Right, as of now, we are using a small DDL->Header conversion program.
My own feeling is that you should explore this subject into your own public project for while, and try to attract a community of volunteers. Then again, once you've reached some kind of milestone you may want to revisit a possible submission to Boost. But I'm certainly no expert in the matter. Good luck to you, --DD
I would have assumed one year minimum before it comes even close. And I am pretty sure I could not cover all aspects all on my own (e.g. OS, DBS, compiler). Regards, Roland