Skip to content

fix(pg-codegen): read unqualified on an empty where, refuse an empty write filter - #1734

Merged
pyramation merged 1 commit into
mainfrom
feat/pg-client-empty-filter
Aug 15, 2026
Merged

fix(pg-codegen): read unqualified on an empty where, refuse an empty write filter#1734
pyramation merged 1 commit into
mainfrom
feat/pg-client-empty-filter

Conversation

@pyramation

Copy link
Copy Markdown
Contributor

Summary

A call site that qualifies a read with a conditional key column — the shape every scoped module read takes — states an empty filter when the scope records no key:

await db.identityProviders.findMany({
  where: module.entityField ? { [module.entityField]: frame.keyValue } : {},
  ...
});

The generated client passed that straight to QueryBuilder.where({}), which throws Empty filter object., so the global-scope path of every such read failed at runtime rather than reading unqualified.

The client now distinguishes "no predicate" from "no rows asked for":

-  if (args.where) query.where(this.filter(args.where));
+  const predicate = this.predicate(args.where);   // undefined when the filter has no keys
+  if (predicate) query.where(predicate);

and because the same emptiness on a write would silently mean every row, update/delete route through required(where, op) and throw instead:

users.update: refusing an empty where filter, which would match every row

findMany/findFirst/count read unqualified; update/delete throw. Two live round-trip tests cover both, and the committed __fixtures__/generated/client.ts is regenerated.

Link to Devin session: https://app.devin.ai/sessions/b1fb8d90ec0a4cd1bd95e3c77c6f6680
Requested by: @pyramation

@pyramation pyramation self-assigned this Aug 15, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@pyramation
pyramation merged commit c9f55eb into main Aug 15, 2026
20 checks passed
@pyramation
pyramation deleted the feat/pg-client-empty-filter branch August 15, 2026 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant