Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(client): safe and unsafe raw queries #8728

Merged
merged 29 commits into from Sep 7, 2021
Merged

Conversation

millsp
Copy link
Member

@millsp millsp commented Aug 13, 2021

Fixes #7142
Fixes #8189
Fixes #8808

BREAKING CHANGE

@millsp millsp marked this pull request as ready for review August 14, 2021 01:07
@millsp millsp added this to the 2.31.0 / 3.0.x milestone Aug 14, 2021
Copy link
Member

@Jolg42 Jolg42 left a comment

Choose a reason for hiding this comment

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

Looks good! (didn't review everything in detail yet though)

See comment

and what's the state of

TODO:

    add runtime checks (exceptions)

Do not merge now I guess, only for next release?

@millsp
Copy link
Member Author

millsp commented Aug 18, 2021

@Jolg42 the current changes are TS-only changes, we'd like to add an error for JS users too (runtime).

@janpio
Copy link
Member

janpio commented Aug 19, 2021

Tracked in #8808 now

Copy link
Member

@Jolg42 Jolg42 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! Added a few comments

And need to check the failing tests

FAIL src/__tests__/integration/happy/raw-transactions/test.ts (5.761 s)
  ● transaction › queryRaw

    All elements of the array need to be Prisma Client promises. Hint: Please make sure you are not awaiting the Prisma client calls you intended to pass in the $transaction function.

      977 |           !p?.isExecuteRaw
      978 |         ) {
    > 979 |           throw new Error(
          |                 ^
      980 |             `All elements of the array need to be Prisma Client promises. Hint: Please make sure you are not awaiting the Prisma client calls you intended to pass in the $transaction function.`,
      981 |           )
      982 |         }

      at PrismaClient.$___transactionInternal (src/runtime/getPrismaClient.ts:979:17)
      at PrismaClient.$___transaction (src/runtime/getPrismaClient.ts:1015:21)
      at PrismaClient.$transaction (src/runtime/getPrismaClient.ts:1031:21)
      at Object.<anonymous> (src/__tests__/integration/happy/raw-transactions/test.ts:21:30)
...
...

Copy link
Member

@Jolg42 Jolg42 left a comment

Choose a reason for hiding this comment

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

Pre-approval, for the small changes in progress

Copy link
Member

@Jolg42 Jolg42 left a comment

Choose a reason for hiding this comment

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

Nice documentation! 💚

@Jolg42 Jolg42 changed the title fix(client)!: safe and unsafe raw queries fix(client): safe and unsafe raw queries Sep 7, 2021
@Jolg42 Jolg42 merged commit 822198e into main Sep 7, 2021
@Jolg42 Jolg42 deleted the break/safe-unsafe-raw-queries branch September 7, 2021 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants