github prisma/prisma 2.0.0-beta.8

latest releases: 5.13.0, 5.12.1, 5.12.0...
pre-release3 years ago

Today, we are issuing the eighth Beta release: 2.0.0-beta.8 (short: beta.8).

Breaking change: Splitting .raw into .queryRaw and .executeRaw

When dealing with raw SQL queries, there are two things we care about - the "return payload", which is being calculated by the SELECT statement we use and the number of affected rows - if we for example do an UPDATE query.

Until now, Prisma Client decided under the hood with a heuristic, when to return the number of affected rows and when to return the result data.
This heuristic broke if you wanted the opposite of what the heuristic returned.
That means that the decision has to be made by the developer using Prisma Client instead.
Therefore, we remove the raw command and replace it with executeRaw and queryRaw.

So what does return what?

  • executeRaw returns the number of affected rows
  • queryRaw returns the result data

The heuristic used to return the data for SELECT statements. So if you upgrade to Beta 8, you need to use queryRaw for your SELECT statements and executeRaw for all SQL queries, which mutate data.

The rule of thumb is: Do not use executeRaw for queries that return rows.
In Postgres, it will work to use executeRaw('SELECT 1), however, SQLite will not allow that.

Fixes and improvements

prisma

prisma-client-js

Credits

Huge thanks to @Sytten, @merelinguist for helping!

Don't miss a new prisma release

NewReleases is sending notifications on new releases.