feat!: Add sql template and loader method#414
Merged
Conversation
This was referenced Feb 1, 2026
Member
Author
cba5a4b to
fa53992
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #414 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 106 108 +2
Lines 13941 14785 +844
Branches 1191 1302 +111
==========================================
+ Hits 13941 14785 +844
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
4d4d971 to
fe4ee5c
Compare
ceba08f to
da8f011
Compare
fe4ee5c to
1c65da3
Compare
ide
reviewed
Feb 4, 2026
packages/entity-database-adapter-knex/src/EnforcingKnexEntityLoader.ts
Outdated
Show resolved
Hide resolved
ide
reviewed
Feb 4, 2026
ide
reviewed
Feb 4, 2026
ide
reviewed
Feb 4, 2026
ide
reviewed
Feb 4, 2026
packages/entity-database-adapter-knex/src/BasePostgresEntityDatabaseAdapter.ts
Outdated
Show resolved
Hide resolved
1c65da3 to
eea3a17
Compare
da8f011 to
39f26e6
Compare
098ab02 to
cbd366a
Compare
ide
approved these changes
Feb 5, 2026
This was referenced Feb 5, 2026
39f26e6 to
831bf34
Compare
cbd366a to
674d0b3
Compare
831bf34 to
c50b36d
Compare
674d0b3 to
b8ff387
Compare
Member
Author
Merge activity
|
wschurman
added a commit
that referenced
this pull request
Feb 9, 2026
# Why This is a long stack, but the goal is to make a place to put postgres-specific loading logic to avoid polluting the core dataloader-based library with logic specific to knex/postgres. And potentially even postgres-specific mutation logic but that's way down the road. The best place for this stuff is in the `entity-database-adapter-knex` library. Therefore, the strategy is (in PR order): 1. Move existing knex/postgres-specific loader methods to a new loader, `knexLoader`. I'm also open to calling this a "Postgres Loader" since the `entity-database-adapter-knex` package already uses postgres-specific queries (and more are added here since this stack eventually produces raw queries) within knex even though technically knex is database agnostic. 1. Move knex-specific logic out of EntityDataManager, move it to its own EntityKnexDataManager. 1. Move these two now-separated pieces into the `entity-database-adapter-knex` package. This requires creating a "plugin" system for database adapters, where when they are included their methods are added to the prototype so that seamless loading continues to work. 1. Add a codemod for these three pieces. 1. Add the first new feature to entity loading, load by tagged template string, which creates a better/safer way to express raw queries for loading entities. Future other things that could be added here (after thorough thought on authorization) are: - Pagination - Create, update, delete by tagged template string - Batch creation - Upsert (maybe) # For Reviewers The most critical things to assess are: - "install" method in #410 - sql tagged template API usability in #414 # How This is part 1. It refactors the loaders by moving `loadManyByFieldEqualityConjunctionAsync`, `loadFirstByFieldEqualityConjunctionAsync`, and `loadManyByRawWhereClauseAsync` to a separate loader. The new pattern for these is: ``` await PostgresTestEntity.knexLoader(vc1).loadManyByRawWhereClauseAsync(...) ``` # Test Plan This has full coverage in new tests.
b8ff387 to
f805905
Compare
This was referenced Feb 10, 2026
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
This is the first new feature afforded by the changes in #407.
It adds a feature that is fairly common amongst typescript ORMs: sql via tagged templates for safe value interpolation into SQL statements.
How
Quite a lot of ORMs have this:
This adds support for it to entity knex.
See tests for examples, especially
PostgresEntityIntegration-test.ts.The idea is that this will replace
loadManyByRawWhereClauseAsyncover the course of a few versions.Test Plan
Full test coverage.