Skip to content

feat(client): implement strictUndefinedChecks#25224

Merged
SevInf merged 2 commits intomainfrom
feat/strictUndefinedChecks
Sep 23, 2024
Merged

feat(client): implement strictUndefinedChecks#25224
SevInf merged 2 commits intomainfrom
feat/strictUndefinedChecks

Conversation

@SevInf
Copy link
Copy Markdown
Contributor

@SevInf SevInf commented Sep 13, 2024

If preview feature is enabled, client-side validator will disallow
explicitly setting fields to undefined. Newly introduced Prisma.skip
could be used for skipping fields explicitly.

This should protect against accidental empty filters on destructive
operations, for example:

prisma.table.deleteMany({
  where: {
    // If `nullableThing` is `null` or `undefined`, this query will remove
    // all data from the table
    property: nullableThing?.property,
  }
})

Intention is to make this behaviour default in Prisma 6.

Full spec

Close prisma/team-orm#1281
Close #20169
Close #20268

/integration

@SevInf SevInf added this to the 5.20.0 milestone Sep 13, 2024
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 13, 2024

size-limit report 📦

Path Size
packages/client/runtime/library.js 186.26 KB (+0.78% 🔺)
packages/client/runtime/library.d.ts 81 B (0%)
packages/client/runtime/binary.js 607.3 KB (+0.24% 🔺)
packages/client/runtime/binary.d.ts 26 B (0%)
packages/client/runtime/edge.js 162.03 KB (+0.92% 🔺)
packages/client/runtime/edge-esm.js 161.83 KB (+0.92% 🔺)
packages/client/runtime/wasm.js 120.86 KB (+1.25% 🔺)
packages/client/runtime/index-browser.js 33.9 KB (0%)
packages/client/runtime/index-browser.d.ts 89 B (0%)
packages/cli/build/index.js 2.13 MB (0%)
packages/client/prisma-client-0.0.0.tgz 2.91 MB (+0.11% 🔺)
packages/cli/prisma-0.0.0.tgz 3.72 MB (+0.09% 🔺)
packages/bundle-size/da-workers-libsql/output.tgz 866.56 KB (+0.06% 🔺)
packages/bundle-size/da-workers-neon/output.tgz 947.58 KB (+0.05% 🔺)
packages/bundle-size/da-workers-pg/output.tgz 966.05 KB (+0.05% 🔺)
packages/bundle-size/da-workers-pg-worker/output.tgz 921.68 KB (+0.05% 🔺)
packages/bundle-size/da-workers-planetscale/output.tgz 883.83 KB (+0.06% 🔺)
packages/bundle-size/da-workers-d1/output.tgz 838.94 KB (+0.06% 🔺)

If preview feature is enabled, client-side validator will disallow
explicitly setting fields to `undefined`. Newly introduced `Prisma.skip`
could be used for skipping fields explicitly.

This should protect against accidental empty filters on destructive
operations, for example:

```ts
prisma.table.deleteMany({
  where: {
    // If `nullableThing` is `null` or `undefined`, this query will remove
    // all data from the table
    property: nullableThing?.property,
  }
})
```

Intention is to make this behaviour default in Prisma 6.

[Full spec](#20169 (comment))

Close prisma/team-orm#1281
Close #20169
Close #20268
@SevInf SevInf force-pushed the feat/strictUndefinedChecks branch from 8b5e77e to d545e2b Compare September 13, 2024 17:02
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Sep 13, 2024

CodSpeed Performance Report

Merging #25224 will improve performances by 36.87%

Comparing feat/strictUndefinedChecks (0a5e87e) with main (9810341)

Summary

⚡ 1 improvements
✅ 2 untouched benchmarks

Benchmarks breakdown

Benchmark main feat/strictUndefinedChecks Change
client generation 100 models with relations 8.1 s 5.9 s +36.87%

Copy link
Copy Markdown
Member

@aqrln aqrln left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me 💯

comments are non-blocking

Co-authored-by: Alexey Orlenko <alex@aqrln.net>
@SevInf SevInf merged commit ce11a90 into main Sep 23, 2024
@SevInf SevInf deleted the feat/strictUndefinedChecks branch September 23, 2024 12:32
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.

Select filter broke and fetched all data from DB where: { shop: undefined }: The entire table data was accidentally deleted

3 participants