joist-orm / joist-orm/joist-orm
Remove prune-undefined behavior from em.find, isolated to findGql
- Dominant language
- TypeScript
- Stars
- 385
- Forks
- 26
- Avg merge
- 8h 55m
- Merged PRs (30d)
- 42
Description
We've had 1 major bug plus the occasional "found before production but still surprises engineers" coming from `em.find` auto-pruning conditions that accidentally?surprisingly end up as `undefined`, i.e.:
```
const approvers = await em.find(Approver, {
user: prior.tradePartnerUser.get,
viaTradePartnerMarketRole: tpmc.role,
viaMarket: tpmc.market.id,
approval: { isFinalized: false },
});
```
It seems like a big enough foot gun that `em.find` should never prune, i.e. ^ `user: undefined` would be treated as "IS NULL" (or throw an error?).
We could probably also add opts:
* `pruneUndefined: false` is default for `em.find`
* `pruneUndefined: true` is the default for `em.findGql`
*
Contributor guide
Research direction
Start at the em.find and em.findGql entry points and trace how undefined conditions are currently pruned. Clarify whether undefined should mean IS NULL or raise an error, then define and verify the proposed default behavior for each entry point.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, typescript
- Domain
- backend, databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100