Repository navigation
fix(routes): run every database query with .run() for interface-database 0.4 - #133
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
ANT-2424. interface-database 0.4.0 made queries non-thenable: a query runs only through
.run().DefaultRoutesawaited queries directly. On interface-database 0.4.0 with mongodb 1.8.0,Newanswered 500 "(intermediate value) is not iterable",Listreturned its total as a query object, andGet,EditandDeletehandled query objects instead of rows (found by ANT-2382 on dms). This PR runs every query, and keeps interface-database 0.3 working.What
srcnow runs through.run(). The sweep is type-aware: with the 0.4 types, oxlint'sawait-thenablereported each awaited query and each query passed toPromise.all. A TypeScript-checker codemod appended.run()to every expression typed as a query, and three optional chains (Schema.get(...)?.…delete()) were fixed by hand.await-thenablenow reports none.DefaultRoutes: Get (fromDatabase(await query.run())), List (Promise.all([queryPaged.run(), queryTotal.run()])), New (insert(...).run()), Edit (theQuery.Getread and theupdate), and Delete.srcthat returns a query, and no.thenon one.Query.Get,Query.List,Query.ListPageandQuery.Deletestill return queries for the caller to run, unchanged.cast. In 0.4,Stream.cast()returnsnew Stream(undefined, this), which copies the wrapper's raw stages into a plain stream and drops the deferred@Joinedlookups.listAsConsumer-style callers then lost every joined field (10 failing tests). In 0.3,castreturnedthis; the wrapper'scastnow does that on every version.docs/10.joined.mdrunsQuery.ListPage(...)and the total with.run(), and saysQuery.*results are queries to run.@antelopejs/interface-databasedev dependency^0.4.0. The test project and the verify harness move to@antelopejs/mongodb1.8.0, which implements 0.4. README tested-with reads 0.4.0.Supported range
@antelopejs/interface-databasestays>=0.1.10 <1.0.0..run()exists on every version from 0.1.10 to 0.4.0, so 0.3 keeps working: the full suite passes on 0.3.3 with mongodb 1.7.0 (220 passing). No peer change, so this fits dms#888's>=0.7.2 <0.8.0pin as a 0.7.x patch.Attention
.run()on whatever they await fromQuery.List(the stream and the total),Query.ListPage,Query.GetandQuery.Delete. Anawaitwithout it answers the query object, as the dms/count/batchsymptom shows.antelopejs-api-diff origin/maincannot build its base, becauseorigin/maindoes not compile against interface-database 0.4. The comparison below buildsorigin/mainwith its own lockfile.SAFETY comments added
None. The suppression budget is unchanged.
Proof
Before:
origin/main'ssrc/index.tsand deferred wrapper, with only the test code moved to.run(), on interface-database 0.4.0 and mongodb 1.8.0. 112 passing, 108 failing:The messages are mostly
expected 500 to equal 200, pluslist failed (500): object is not iterableandexpected undefined to equal 'Alice Carter'(joined fields lost aftercast).After, on this head with interface-database 0.4.0 and mongodb 1.8.0:
pnpm run checks11 passed, 0 failed, with 220 tests.pnpm exec tsc -p docs/tsconfig.jsonpasses.0.3: the same head with interface-database 0.3.3 and mongodb 1.7.0 gives 220 passing.
verify-interface on this head (interface-database 0.4.0, mongodb 1.8.0), all 13 features: 55 of 55 journeys pass.
Declarations,
origin/mainbuilt with its own lockfile against HEAD: no.d.tsdiffers. Runtime exports ofindex,metadataandcomponents(names andtypeof): identical, 27 names.