Repository navigation
fix(database): skip undefined relational filter values under drizzle-orm rc - #1789
Merged
Merged
Conversation
…orm rc drizzle-orm 1.0.0-rc throws "Unexpected 'undefined' in filter value" for any undefined key in a relational `where` (top level or inside `with`); beta-22 skipped them. Repositories such as flow `buildWhere` leave optional filters undefined, so opening Flows failed in production after #1759. Patch the shared relational query builder's findMany/findFirst to strip undefined values from the config, covering every db.query.* and tx.query.* call, and add a regression test.
1 task done
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.
Summary
Production incident: opening Flows fails with
Unexpected 'undefined' in filter value. Use 'EmptyFilter' if you want the filter field to be skipped.drizzle-ormfrom1.0.0-beta.22to1.0.0-rc.6. The rc throws on anyundefinedvalue in a relationalwhere(top level or insidewith), where beta skipped it.flowRepository.buildWhereleaves optional filters (folderId,name,active,enableInInbox) asundefined, solistWithVersions→tx.query.flowModel.findMany({ where })throws whenever the list is opened without those filters. chore(database): upgrade drizzle-orm and drizzle-kit to 1.0.0-rc.5 #1759 had already wrappedrelationsFilterToSQL(used bycount) but notdb.query.*.packages/database/src/client.tswrapsfindMany/findFirston the shared relational query builder prototype so each call's config goes throughstripUndefinedfromrelations-filter.ts. This restores beta behaviour for everydb.query.*andtx.query.*call, not only Flows, since other repositories buildwhereobjects the same way.stripUndefinedonly walks plain objects and arrays; SQL, Date, Placeholder and function values are left untouched.Test plan
packages/database/__tests__/relational-query-undefined.test.ts: 3 of its 4 tests fail with the production error before the fix and pass after it@chatbotx.io/databasetest suite: 2187 passed, 942 skipped (DB-only)pnpm lintand pre-commitcheck-types(26/26 packages) pass