feat: add callable parameterized compiled queries - #241
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.
Named
parameter('name')placeholders now turn schema-backed PostgreSQL SELECTs into callable queries. Argument types come from the selected columns, and distinct names become positional arguments in construction order. Repeated names share one argument.The first invocation or SQL inspection caches the SELECT statement, binding slots and decoder. Later calls use fresh bindings through Knex's normal runner without rebuilding the statement. Immutable shape derivatives have separate plans; transaction derivatives from the same client share a plan. Captured selectors and customizers are never replayed during binding.
Includes grouped predicates, fixed membership/range slots, alias joins, typed relations, STI/CTI customizers, storage-aware Date/exact-numeric/JSON arguments, preserved null semantics, and ORM identity tracking. Unbound terminals/writes and unsupported placeholder positions are rejected. This covers fixed-shape SELECTs; it does not manage named server-side prepared statements or cache results.
Updates both package guides and documentation pages, removes completed F08 from the candidate list, and includes minor changesets for knex-schema and ORM.
Validation:
npm run lintnpm run buildnpm run test(4,748 tests; no type errors)npm run bench -- --project benchmarks libs/benchmarks/src/compiled-query.bench.tsseparates construction, first compilation, warmed binding and runner/decoder overhead without database latency