hediet / ts-typed-sql

A fully typed sql builder. Not maintained anymore, use it for your inspiration.
https://hediet.github.io/ts-typed-sql/
54 stars 4 forks source link

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

Open phiresky opened 7 years ago

phiresky commented 7 years ago
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.