|
Boost : |
Subject: Re: [boost] Request for Interest in several Modules
From: Roland Bock (rbock_at_[hidden])
Date: 2012-01-12 06:10:57
On 01/12/2012 10:20 AM, Thorsten Ottosen wrote:
> Den 12-01-2012 08:43, Roland Bock skrev:
>> On 01/11/2012 07:31 PM, Thorsten Ottosen wrote:
>
>>> Maybe we can get 90% of it by something as simple as
>>>
>>> class Users
>>> {
>>> BOOST_DECLARE_SQL_CLASS( "USERS" );
>>>
>>> BOOST_SQL_VAR( int, "column_age", age );
>>> BOOST_SQL_VAR( std::string, "column_role", role );
>>> ...
>>> };
>>>
>>>
>>> -Thorsten
>>
>> Probably yes, but based on our current code generator I'd say it would
>> be quite a lot of macro code, which I find hard to debug.
>
> Well, I don't see why it has to be that way. We can maybe avoid macros
> a little by doing
>
> class Users
> {
> BOOST_DECLARE_SQL_CLASS( "USERS" );
> BOOST_DECLARE_SQL_COLUMNS( "column_age", age, "column_role", role
> );
>
> boost::sql::variable<int> age;
> boost::sql::nullable_variable<std::string> role;
> ...
> };
>
> AFAICT, the only thing you have to debug is mismatch in the
> column/table names. But that should be easy to detect at run-time, thus
> easy to catch in unit-tests.
>
> -Thorsten
You may be very well be right. Currently we generate lots of additional
code, to allow for stuff like this:
Users users;
users.insert(
users.age(42),
users.firstName("Roland"),
users.lastName("Bock"));
The insert method knows the required columns (you can specify the
non-required columns, too, of course).
It is certainly possible that this can be done with as little code as
you suggested and with very little amounts of macro code. I'll
definitely think about it in more detail.
Regards,
Roland
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk