ts-typed-sql
ts-typed-sql copied to clipboard
Subquery in insertInto fails with "TypeError: Converting circular structure to JSON"
const id = 123;
await db.single(
sql
.insertInto(a)
.value({
id,
foo: sql
.from(bar)
.where({ id })
.select(bar.x)
.asExpression()
})
);
creates a query like
INSERT INTO roulette.games(id, foo) VALUES ($1, $2)
Trying to pass the inner query directly to pg.