ts-typed-sql icon indicating copy to clipboard operation
ts-typed-sql copied to clipboard

Subquery in insertInto fails with "TypeError: Converting circular structure to JSON"

Open phiresky opened this issue 8 years ago • 0 comments

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.

phiresky avatar Nov 10 '17 23:11 phiresky