Today, we are issuing the 2.2.0
stable release.
Major improvements
Next to a lot of bug fixes, this version includes a number of new features!
Quick fix suggestions in Prisma VSCode Extension
The Prisma VS Code extension now helps you fix any accidental typos and offers more convenient "Quick Fixes" right inside your editor.
Make datasource provider
dynamic via environment variables
The provider
field on the datasource
defininitions in your Prisma schema now also accepts an array of strings (instead of just a plain string). This can be helpful when you want to switch environments which point to different databases based on an environment variable. Learn more about this feature here.
datasource db {
provider = ["sqlite", "postgres"]
url = env("DATABASE_URL")
}
Experimental features
Already existing experimental features
Just a quick reminder: In v2.1.0
we introduced two experimental features, namely connectOrCreate
and transactionApi
. In case they're useful for you, please give them a try! They stay experimental in this release.
Re-Introspection
We were able to continue to improve the re-introspection flow based on your feedback. Thanks!
Aggregations API
While Prisma Client already provides a count
query for each model, we now introduce further aggregation functionality for number fields.
If your model has a field of type Int
or Float
, the following aggregations will be available:
sum
: Sum up all values of a field for the selected rows.min
: Get the minimum value for a field for the selected rows.max
: Get the maximum value for a field for the selected rows.avg
: Get the average value for a field for the selected rows.
Example
Note, that the count
API is always available, while sum
, min
, max
, and avg
are only available for a model if it has a number field.
Prisma Schema | Prisma Client Query | Result |
---|---|---|
model User {
id Int @id
age Int
name String
} |
const result = await prisma.user.aggregate({
where: { age: { gt: 5 } }, // optional
count: true,
avg: {
age: true,
},
max: {
age: true,
},
min: {
age: true,
},
sum: {
age: true
}
}) |
{
"count": 10,
"avg": {
"age": 80
},
"max": {
"age": 163
},
"min": {
"age": 5
},
"sum": {
"age": 800
}
} |
Feature flag
In order to enable this experimental feature, note that you need to set the feature flag aggregateApi
in the Prisma Client generator block in your schema:
generator client {
provider = "prisma-client-js"
experimentalFeatures = ["aggregateApi"]
}
Please share your feedback on how this feature works for you. We are interested in both positive and negative feedback, so we know if this feature is already ready for production! (If encounter any problems, please open a new issue here).
Fixes and improvements
prisma
- Make datasource provider dynamic via environment variables
- Introspection doesn't recognize enums in PostgreSQL
- [Introspection] Investigate if our Introspection queries (can) return the correct order of columns
- PrismaClient throw error on missing is env even when overwriting database connection
- Pagination: cursor is ignored when using negative take argument
- Generator error hidden
prisma generate
throws exit code 0 in case of error caused by denied keywords- .env not loaded when running
prisma migrate (save | up | down) --schema <file-path>
- MySQL: Unreachable database host leads to unknown error
- Prisma format ignores newlines at the end of files
- Prisma introspection should add a trailing newline
- Introspection: Use env vars to override introspection binary with --url --print
- @prisma/engine-core's package.json uses a github url for its version of undici
- Unify prisma introspect and prisma introspect --url wrt re-introspection
- Strange @@relation error message when running prisma generate
- Support selections using basic aggregations
- Re-introspection error for renamed relations when there are multiple relations to the same table
- Introspection doesn't add or loses trailing new line of schema file
- UUID Cursor Pagination
- Schema validation: @default(autoincrement()) on a String field should be rejected
- Switch to undici
- Introspect removes experimental features from schema
- Add new line checks to integration tests
prisma-client-js
- Add more integration tests for unhappy paths
- Better error message when generated Client and local Prisma schema are out of sync
- Multiple quick
count
requests result inInvalid prisma.web_hooks.count invocation
- Wrong jsDocs annotations for
create
anddelete
- Raw API concerns
- Improve sqlite error messages
- JSON Filter does not work
- Bulk Operations Naming Conflict
- Transaction API is not writing the transaction
- Expose debug mode to trigger a panic for reproductions
migrate
migrate up
tells me to read in./migrations/MIGRATION_ID/README.md
- Create new SQL Database missing first char on name
migrate save/up
hangs while creating databaseREADME.md
of migration folder includesquaint
in SQL- Validate
@default(now())
so that it only can be used in DateTime fields
vscode
- Publish lsp server to npm
- Quick Fix for fields with unknown types
- Remove test cases that point to a four digit versioning scheme
- Run integration tests on an extension release
- Add instructions for each feature in README
- Composite keys are not considered valid?
- README on marketplace does not show Prisma Logo
- Lerna bootstrap does not install all dependencies
- Connection to server got closed. Server will restart.
- Investigate
***
in GH action output
studio
- Allow for column resizing
- Table scroll area should start underneath table header
- Select range of records when holding shift key
- Table's loading illustration may overlap with the table content
- Tooltips for table header columns
- Type to edit Enums and Booleans with autocomplete
- Copy & paste from a cell does not seem to work
- A better databrowser table
- In the "connect to X" view I would like to connect when clicking on a row
- Loading state shows unexpected data
- Scrolling down in relation accordion does not show entries
- After editing relation only the number of unsaved changes is shown in main table
- Styling of editing Int is different from editing String
- Loading state is not really indicated