vulcyn
vulcyn copied to clipboard
The distinction between Expr and Selectable isn't great
It felt mildly forced to have a whole separate structure for Expr but now it's starting to become a bit of an issue.
For example,
db.users.age.gte(21)
yields an Expr, but it should also be Selectable<bool> so that one can do
const {id, name, age} = db.users;
await db.select({
id,
name,
canDrink: age.gte(21),
});
which currently does not work because the result of gte is an Expr instance and not Selectable<bool>.
Secondary Motivation
Doing this should also make it easier to do deeper chaining with respect to columns and operations on them and maybe make some of the code in ColumnWrapper more generic. For example, when implementing arrays, I want to be able to do
const {pay_by_quarter} = db.people;
select(...).where(pay_by_quarter.idx(1).neq(pay_by_quarter.idx(2))
Since idx(1) doesn't refer to a column, it can't be a ColumnWrapper, but it supports most of the same operations.