Subject: Re: [boost] sqlpp11: SQL for C++
From: Roland Bock (rbock_at_[hidden])
Date: 2013-11-11 17:50:53
On 2013-11-11 23:22, Edward Diener wrote:
> On 11/11/2013 4:51 PM, Roland Bock wrote:
>> On 2013-11-11 22:22, Edward Diener wrote:
>>> On 11/11/2013 10:01 AM, Roland Bock wrote:
>>>> On 2013-11-11 15:36, Edward Diener wrote:
>>>> With that said the idea of your library looks very interesting. I have
>>>> always favored an SQL C++ library as one dealing with SQL syntaxes as
>>>> templated C++ constructs via a DSEL rather than SQL strings of
>>>> statements. The only downside to your library is that on-the-fly SQL
>>>> queries based on run-time analysis of database table structure is
>>>> impossible with such a design, so that I would suggest you also
>>>> provide a way of generating an SQL string at run-time as a query, with
>>>> all syntax checking of the string as an end-user responsibility.
>> Actually, you can build the query almost completely at runtime, already.
>> There is the verbatim method for instance.
>> auto s = dynamic_select(db).dynamic_columns().dynamic_from();
>> const auto cake = sqlpp::verbatim<sqlpp::text>("cake");
>> for (const auto& row : db.run(s))
>> std::cout << row.at("cake") << std::endl;
>> At the moment, I can think of the following limitations:
>> * You cannot use verbatim() as a table yet, but that extension would
>> be almost trivial.
> I am not sure what this means. The end-user has to be able to specify
> a table to be used in a valid SQL query, so a verbatim query must
> accept a table. But I suspect you mean something else.
Yeah, that was neither clear nor thought through. Sorry. What I should
have written is:
As of now, you cannot use strings in from():
auto s = dynamic_select(...).dynamic_from();
s.add_from("my_table"); // compile error today
But I'll make that compile rather sooner than later.
>> * When used as an expression, verbatim() must represent exactly one
> That is fine. There is little need in practical code for creating more
> than one verbatim query and running it in multi-threaded code.
>> * All dynamic fields are returned as text representations, implicitly
>> convertible to std::string
> That is fine. Here since the end-user is doing on-the-fly run-time
> creation of queries it should be his responsibility of parsing the
> return data.
>> sqlpp11 would still do all the syntax checks, assuming that your
>> verbatim strings are valid expressions (e.g. correct column names).
> That would be great if it is not too much work for sqlpp11 ! Even
> without syntax checking for verbatim queries it is a worthwhile feature.
Hmm? I guess that wasn't clear enough as well. I meant:
If you are using verbatim(), sqlpp11 assumes that you know what you are
doing. It will not check those strings.
But under the assumption, that the provided strings are correct, the
EDSL will ensure that the overall syntax of the query will be OK. So you
only have to worry about your verbatim strings.
I will try to get some sleep now, and to write clearer sentences
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk