getTableColumns() for `with`?

Hi, is there any alternative to getTableColumns() for with CTEs? If I use the example from the docs:
const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));
const result = await db.with(sq).select().from(sq);
const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));
const result = await db.with(sq).select().from(sq);
How would I get the columns of sq? Calling getTableColumns(sq) does not work. It looks like sq._.selectedFields works as an alternative, but is that the right way?
2 Replies
Jetrak
JetrakOP2d ago
Bump
Mario564
Mario5642d ago
There's no "elegant" solution to this, the way you're doing it via sq._.selectedFields is currently the only way Although you can easily extract this into a your own helper function
Want results from more Discord servers?
Add your server