On Sunday, 3 January 2016 at 14:32:48 UTC, Jacob Carlborg wrote:
On 2016-01-02 21:48, Sebastiaan Koppe wrote:

I meant that you generate the struct from the DSL, and then migration
code from that struct.

I don't think I understand, it seems complicated.

Suppose you have this:

mixin(db(`
Entity Person
  Fields
    name -> string
    age -> integer
  Query
    byAge(a -> integer) -> age == a
`));

which generates something like this:

struct Person
{
  string name;
  int age
}
auto getPersonByAge(DB db, int a)
{
return db.prepare!Person("SELECT name,age FROM Person WHERE age = ?").query(a);
}

and then later in time:

mixin(db(`
Entity Person
  Fields
    name -> string
    age -> integer
    phone -> string
  Query
    byAge(a -> integer) -> age == a
`));

Given that you have access to both version it is easy to generate migration code for the phone field.

Maybe it is contrived, but I think it shows you can do more with the DSL than just validating queries.

Reply via email to