github TanStack/db @tanstack/db@0.15.0

latest releases: @tanstack/trailbase-db-collection@0.1.121, @tanstack/db-sqlite-persistence-core@0.4.10, @tanstack/cloudflare-durable-objects-db-sqlite-persistence@0.2.35...
3 hours ago

Minor Changes

  • Load includes only for the rows a windowed query or a findOne shows. A live query with an orderBy, or a findOne, no longer evaluates the includes in its own select (a child query, toArray, materialize, or findOne) for rows outside the rows it shows, whether limit and offset set the window or setWindow moves it. A late page now costs about the same as the first one. With distinct, the query no longer loads children for every source row. A where that names correlation values starts their child loads at once only when no enclosing query is windowed or a findOne, and either the query is neither windowed nor a findOne, or it is a findOne that shows one row for one named correlation value, with no offset, and offset 0 at start if a window was requested before start. Any other window or findOne, including a window that setWindow requests later, can drop those rows. Includes inherited from a subquery in from, and includes passed into fn.select, still load for every row before the window. (#2156)

    setWindow now moves only the query's own window. A window inside a from subquery, a joined subquery, or an include child no longer answers it, so a query that is neither windowed nor a findOne throws SetWindowRequiresOrderByError, and one that is neither windowed nor an ordered findOne rejects offset moves.

    Breaking: a findOne keeps its compiled limit, 1 (or 0 for .limit(0).findOne()). An ordered findOne has a movable window: getWindow() returns { offset, limit } with that limit, and setWindow can move its offset but now throws the new SetWindowFindOneLimitError for any other limit; before, setWindow({ limit: 3 }) made a findOne show three rows. An unordered findOne is a fixed one-row result that accepts only its compiled limit at offset 0: getWindow() returns { offset: 0, limit: 1 }, and a nonzero offset throws SetWindowRequiresOrderByError, as .offset() without orderBy does.

Patch Changes

  • An ordered, limited live query over an on-demand source without an index no longer leaves its window short when a LEFT-joined filter removes rows from the loaded prefix. For example, an anti-join could show an empty window after a visible row was deleted. Such a plan now counts the rows its window still needs, and reads the full source when its prefix cannot fill the window. (#2132)

Don't miss a new db release

NewReleases is sending notifications on new releases.