tink_sql
tink_sql copied to clipboard
Plain functions for conditions
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.
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).