On Sat, 21 Sep 2013 00:51:52 GMT, simendsjo wrote:

I didn't want to write all those "copy from row to object", so I hacked together something with UDAs

    @dbexpr("FROM user ORDER BY username ASC")
    struct UserListItem
    {
        @dbexpr("user_id")
        int user_id;

        @dbexpr("username")
        string username;
    }
    const users = db.queryExpr!UserListItem;

    res.render!("user.list.dt", req, users);

The little queryExpr method just translates this to a standard select.
Every struct/class field is added as a sql field, and the one at the top is added last.
They can be as complex as you'd like, and they can use query parameters (although the parameter values isn't added from the struct).

And of course, everything is build in at compile time, so there is no performance overhead - gotta love D! :)

Nice!

I just wish it was possible to concentrate on the nice things, but most time seems to be needed to work around compiler bugs (again, the situation was better for a while)... </rant>

Btw. did you already look at hibernated? It seems to be on hold for a while now, though, and misses a patch to use the latest mysql-native version.