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

feat(deps): update prisma to 2.23.x #1072

Merged
merged 2 commits into from
May 21, 2021
Merged

feat(deps): update prisma to 2.23.x #1072

merged 2 commits into from
May 21, 2021

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented May 4, 2021

WhiteSource Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
@prisma/client (source) 2.21.x -> 2.23.x age adoption passing confidence
@prisma/client (source) 2.21.2 -> 2.23.0 age adoption passing confidence
@prisma/fetch-engine (source) 2.21.2 -> 2.23.0 age adoption passing confidence
@prisma/get-platform (source) 2.21.2 -> 2.23.0 age adoption passing confidence
@prisma/migrate (source) 2.21.2 -> 2.23.0 age adoption passing confidence
@prisma/sdk (source) 2.21.2 -> 2.23.0 age adoption passing confidence

Release Notes

prisma/prisma

v2.23.0

Compare Source

Today, we are excited to share the 2.23.0 stable release 🎉

🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟

Major improvements & new features
JSON Filtering is now in Preview

Starting today, you can now filter rows by data inside a Json type. JSON filtering support is available in PostgreSQL and MySQL. You can try it today by adding the filterJson preview flag to your generator block. This has been one of our most popular feature requests, so we're very excited to be getting it into your hands!

To get an idea of how JSON filtering works, let's see how you might query application logs stored in your database. Given the following Prisma schema:

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["filterJson"]
}

model Log {
  id      Int    @​id @​default(autoincrement())
  level   Level
  message String
  meta    Json
}

enum Level {
  INFO
  WARN
  ERROR
}

And the following records in your PostgreSQL database:

id level message meta
2 INFO application listening on port 3000 {"host": "bob"}
3 INFO upgrading account {"host": "alice", "request_id": 10}
4 INFO charging customer {"host": "alice", "amount": 20, "request_id": 10}
5 ERROR credit card expired {"host": "alice", "amount": 20, "request_id": 10}
6 INFO signing up {"host": "bob", "request_id": 1}
7 INFO application listening on port 3000 {"host": "alice"}
8 INFO signed up {"host": "bob", "email": "james@gmail.com", "request_id": 1}

We can now filter logs by the data inside the meta field. Let's query by the request_id inside the meta field to track the journey that led up to the error.

We can write the following query:

const logs = await prisma.log.findMany({
  where: {
    meta: {
      // path looks for the request_id key inside meta
      path: ["request_id"],
      // and we select rows whose request_id is 10
      equals: 10,
    },
  },
  orderBy: {
    id: "asc",
  },
});

Giving us the entire journey of this person's request:

[
  {
    id: 3,
    level: 'INFO',
    message: 'upgrading account',
    meta: { host: 'alice', request_id: 10 }
  },
  {
    id: 4,
    level: 'INFO',
    message: 'charging customer',
    meta: { host: 'alice', amount: 20, request_id: 10 }
  },
  {
    id: 5,
    level: 'ERROR',
    message: 'credit card expired',
    meta: { host: 'alice', amount: 20, request_id: 10 }
  }
]

Please note that the path syntax varies depending on the database. We pass the path query directly to the database, so there will be syntactical differences.

For example, querying by key in Postgres is request_id, while in MySQL it would be $.request_id. Please consult your database's documentation to learn more.

If you run into any questions or have any feedback, we're available in this issue.

Improvement for prisma db seed

In previous versions, a seed file could only be executed as a script. prisma db seed was simply executing the script by either calling node ./prisma/seed.js for JavaScript or ts-node ./prisma/seed.ts for TypeScript.

Now, you can directly export a function that Prisma executes on your behalf. Here's the rules that describe the new behavior: Prisma checks if the seed file has ...

  • ... an exported function named seed and executes it
  • ... an exported function (via a default export) and executes it

If there's no function exported as seed or via a default export, the behaviour of prisma db seed is exactly the same as before, meaning it will simply be executed as a script file.

Breaking changes
Options in groupBy queries are now prefixed with an underscore

The options in groupBy are now prefixed with an underscore, for example:

// API
const result = await prisma.user.groupBy({
  by: ['name'],
-   count: true,
+   _count: true,
})

Here's an overview of the exact changes of each option:

Before 2.23.0 2.23.0 and later
count _count
max _max
min _min
avg _avg
sum _sum

Note that this also changes the names of the fields in the objects that are returned by Prisma Client. For example, in the above case you now access the returned count value like so:

- console.log(result.count)
+ console.log(result._count)

We made this change to avoid clashes with user-defined fields. You can learn more about the problem in these issues.

We're sorry for the inconvenience! If you have any questions or need any help, please reach out in this discussion.

Deprecations
Deprecating options in aggregate queries

With the changes to groupBy discussed above and recent features like orderBy an aggregate, we took this opportunity to unify min, max, avg, sum and count keywords across Prisma Client queries.

  const result = await prisma.user.aggregate({
-   avg: {
+   _avg: {
      age: true,
    },
  })

- result.avg
+ result._avg

Similar tpo groupBy, this is the case for all of our aggregations:

Before 2.23.0 2.23.0 and later
count _count
max _max
min _min
avg _avg
sum _sum

This is not a breaking change. The aggregate queries you wrote prior to 2.23.0 will continue to work as expected. We ask that you make adjustments when you can to future-proof your application.

If you have any questions or need any help, please reach out in this discussion.

Fixes and improvements
Prisma Migrate
Prisma Client
Prisma Studio
Prisma Engines
Credits

Huge thanks to @​Sytten, @​schiller-manuel, @​mongolyy, @​paularah, @​Iamshankhadeep, @​meeq for helping!

📺 Join us for another "What's new in Prisma" livestream

Learn about the latest release and other news from the Prisma community by joining us for another "What's new in Prisma" livestream.

The stream takes place on Youtube on Thursday, May 20 at 5pm Berlin | 8am San Francisco.

🌎 Prisma Day is coming

Save the date for Prisma Day 2021 and join us for two days of talks and workshops by the most exciting members of the Prisma community.

We look forward to seeing you there!

v2.22.1

Compare Source

Today, we are issuing the 2.22.1 patch release.

Fix

Prisma CLI

v2.22.0

Compare Source

Today, we are excited to share the 2.22.0 stable release 🎉

🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟 

Major improvements & new features
prisma db push is now Generally Available

prisma db push enables you to update the database schema from the Prisma schema file, without generating any migrations.

This is especially useful when prototyping a new feature, iterating on the schema changes before creating migrations or generally if you are at stage of your development process, where you don't need to persist the schema change history via database migrations.

It is now promoted from Preview to General Availabilty.

You can find more info on prisma db push in the official docs.

Deprecation of array notation for provider fields

In this release, we are also entirely removing the array notation for the provider fields on datasource blocks. This has been deprecated since 2.11.0 (November 2020).

You can read more about our reasons for this deprecation here.

Prisma Client Go gets support for AND operator

We've always had OR, but this release we also added AND support:

first, err := client.User.FindFirst(
	User.Or(
		User.Email.Equals("john@example.com"),
		User.And(
			User.Name.Equals("John"),
			User.Username.Equals("johno"),
		),
	),
).Exec(ctx)

Learn more in our docs.

Fixes and improvements
Prisma Migrate
Prisma Client
Prisma Studio
Prisma engines
Credits

Huge thanks to @​Sytten, @​schiller-manuel, @​mongolyy, @​paularah, @​Iamshankhadeep, @​meeq for helping!

📺 Join us for another "What's new in Prisma" livestream

Learn about the latest release and other news from the Prisma community by joining us for another "What's new in Prisma" livestream.

The stream takes place on Youtube on Thursday, May 06 at 5pm Berlin | 8am San Francisco.


Configuration

📅 Schedule: At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

♻️ Rebasing: Renovate will not automatically rebase this PR, because other commits have been found.

🔕 Ignore: Close this PR and you won't be reminded about these updates again.


  • If you want to rebase/retry this PR, check this box.

This PR has been generated by WhiteSource Renovate. View repository job log here.

@kevinwolfcr
Copy link

Any ETA on releasing this? I am having errors when trying to install using NPM 7 because my project uses @prisma/client 2.22.0.

@renovate renovate bot changed the title feat(deps): update prisma to 2.22.x feat(deps): update prisma to 2.23.x May 19, 2021
@janpio
Copy link
Contributor

janpio commented May 19, 2021

Has been updated to 2.23.0 and now unfortunately failing tests :/

Update: Failing test is a dmmf diff, which is related to the breaking changes and deprecations in 2.23.0: https://github.com/prisma/prisma/releases/tag/2.23.0

@renovate renovate bot force-pushed the renovate/prisma branch 3 times, most recently from 97b0ddd to 24fe9ea Compare May 20, 2021 16:53
@janpio janpio requested a review from jasonkuhrt May 20, 2021 19:08
@jasonkuhrt jasonkuhrt merged commit 583929e into main May 21, 2021
@jasonkuhrt jasonkuhrt deleted the renovate/prisma branch May 21, 2021 00:25
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.

None yet

4 participants