On 16/05/14 02:29, Dylan Knutson wrote:
Hi all,

I'd like to announce the initial version of Regal, an SQL relational
algebra builder for D. It's intended as a backbone for a relational
database ORM, in line with how Arel works with Rails' ActiveRecord, but
nearly any project that generates SQL dynamically can benefit from it.
The goal of the library is to make programmatically generating queries
simple (and more robust than simple string concatenation), and to be
database agnostic (it's very easy to write database specific printers
for a Regal AST).

There are extensive examples available in the Readme about how to use
the library, from generating very simple queries (SELECT * FROM users)
to multiple chained joins and nested constraints. Here's an example from
the documentation: finding a user with ID 1:

```
auto users = new Table(
   "users", // table name
   "id",    // the rest are columns
   "name",
   "created_at",
   "updated_at");

Does this need to be a class, can it be a struct instead?

// SELECT * FROM users WHERE users.id = 1 LIMIT 1
users
   .where(users.id.eq(1))
   .limit(1)
   .project(new Sql("*"))
   .to_sql
```

Why is 'new Sql("*")' needed? If you need to have a specific type, could it be a struct instead?

The library can be found at: https://github.com/dymk/regal
And the dub package: http://code.dlang.org/packages/regal

This all looks pretty nice :). Does it work at compile time?

--
/Jacob Carlborg

Reply via email to