Changelog - 2026-10-25
RecursiveTreeSql reads tables in a named schema and takes an anchor filter
Bug Fix EnhancementIn one line. RecursiveTreeSql.walk now works on a table declared with pgSchema('commerce').table(...), and anchorFilter lets you keep a row out of the walk at its starting point as well as along it.
What changed
- The schema is kept.
walkused to read"merchants"instead of"commerce"."merchants", so the walk hit the wrong relation or none. A Postgres table in a named schema is now emitted as"schema"."table". A table in the default schema stays unqualified, and SQLite is unchanged. anchorFilteris new. It is ANDed into the anchor term'sWHERE, the wayrecursiveFilteris ANDed into the recursive term.walkstill applies no soft delete by itself. It takes a table, not a model, so pass both filters to exclude deleted rows.
typescript
RecursiveTreeSql.walk({
name: 'descendants',
table: merchants,
rootId,
direction: RecursiveTreeDirections.DOWN,
maxDepth: 10,
anchorFilter: sql`deleted_at IS NULL`,
recursiveFilter: sql`t.deleted_at IS NULL`,
});Who is affected
- Code that walks a table in a named Postgres schema. The walk now reads the right table. If you worked around the missing qualifier with a view or a search path, you can drop the workaround.
- Code that walks a table in the default schema, or SQLite. No action needed.