tink_sql icon indicating copy to clipboard operation
tink_sql copied to clipboard

Plain functions for conditions

Open back2dos opened this issue 8 years ago • 1 comments

Now that we have short lambdas in the language, I think this is a nice macro free way to write conditions:

db.User.where(u -> u.name == "JohnDoe");

Also with #14 one will be able to write:

db.User.where(db.User.fields.name == "JohnDoe");

So the functions should take a Fields<T>->Condition<Owner<T>> or a Condition<Owner<T>> (by implicit cast from the latter to the former).

Last I checked the current makeFilter botches up completion, so my proposal is to make where and on simple functions and add WHERE and ON as macros for a more SQL-like syntax for those who want it.

back2dos avatar May 22 '17 06:05 back2dos

I should add that the WHERE and ON should ideally also be able to do db.User.WHERE(name == "JohnDoe") and even db.User.join(db.Post).ON(User.id == author) (where author is resolved as Post.author` as it's unambiguous).

back2dos avatar May 22 '17 06:05 back2dos