ts-typed-sql
ts-typed-sql copied to clipboard
Output some warning when doing `x = x`
With .innerJoin or .leftJoin it's very easy to accidentaly get the parameters the wrong way around and there is no way to notice. For example
sql.from(chkTable)
.innerJoin(menu.meal)
.on({ _mensa: menu.meal._mensa, _line: menu.meal._line, _date: menu.meal._date, _mealIndex: menu.meal._mealIndex })
.select(menu.meal.$all)
generates
SELECT "menu"."meal".* FROM (VALUES ($1, $2, $3, $4), ($5, $6, $7, $8))
AS "temp"(_mensa, _date, _line, _mealIndex)
JOIN "menu"."meal"
ON "menu"."meal"."_mensa" = "menu"."meal"."_mensa"
AND "menu"."meal"."_line" = "menu"."meal"."_line"
AND "menu"."meal"."_date" = "menu"."meal"."_date"
AND "menu"."meal"."_mealIndex" = "menu"."meal"."_mealIndex"
Which obviously gives unintended results