Today, we are issuing the sixth Beta release: `2.0.0-beta.6` (short: `beta.6`).
More powerful `raw` queries with Prisma Client
Thanks to zachasme and Sytten, the `prisma.raw` command became more powerful in https://github.com/prisma/prisma/pull/2311. There are two changes we introduce for `raw`:
Expose `sql-template-tag` helpers
Prisma Client's `raw` mode utilizes the [`sql-template-tag`](https://github.com/blakeembrey/sql-template-tag) library. In order to construct raw SQL queries programmatically, Prisma Client now exposes a few helper functions:
ts
import { sql, empty, join, raw, PrismaClient } from 'prisma/client'
const prisma = new PrismaClient()
const rawQueryTemplateFromSqlTemplate = await prisma.raw(
sql`
SELECT ${join([raw('email'), raw('id'), raw('name')])}
FROM ${raw('User')}
${sql`WHERE name = ${'Alice'}`}
${empty}
`
)
Allowing programmatic positional parameters
Sometimes, a static template string is not enough. Then constructing a string dynamically is the right choice. For this situation, we added support for arbitrary positional parameters:
ts
const result = await prisma.raw(
'SELECT * FROM User WHERE id = $1 OR email = $2;',
1,
'ema.il'
)
Other improvements
- You can now enable pgBouncer in your connection URL by adding the `?pgbouncer=true` parameter (`forceTransactions` from the `PrismaClient` is now deprecated and will be removed in an upcoming release)
- Improved handling of comments in `prisma format`
- Various improvements to Prisma's VS Code extension (e.g. better error messages and debug information)
Fixes and improvements
`prisma`
- [[Introspection] Better `introspect` success message](https://github.com/prisma/prisma/issues/1554)
- [DigitalOcean Postgres + PGBouncer Issues](https://github.com/prisma/prisma/issues/1638)
- [`&sslcert=server-ca.pem` in PostgreSQL connection url throw `Error opening a TLS connection: One or more parameters passed to a function were not valid.`](https://github.com/prisma/prisma/issues/1651)
- [Prisma generate --watch errors](https://github.com/prisma/prisma/issues/1816)
- [Introspect default value with backslashes causes problem when generating client](https://github.com/prisma/prisma/issues/1888)
- [Prisma DMMF parses comments as fields docs](https://github.com/prisma/prisma/issues/1987)
- [Cascade delete does not work unless relation is optional](https://github.com/prisma/prisma/issues/2212)
- [Special-case syntax error for multiple unnamed arguments in directive in the schema parser](https://github.com/prisma/prisma/issues/2317)
- [Error on table update using a mapped field in where clause](https://github.com/prisma/prisma/issues/2329)
- [Add renovate bot for dependencies](https://github.com/prisma/prisma/issues/2334)
- [Prisma Schema: Add .prisma syntax highlighting for Sublime Text](https://github.com/prisma/prisma/issues/2336)
- [Simple filtering for JSON](https://github.com/prisma/prisma/issues/2345)
- [Panic calling findOne with mapped unique key fields](https://github.com/prisma/prisma/issues/2353)
- [Validation issue for schemas with compound foreign keys](https://github.com/prisma/prisma/issues/2387)
- [[introspect] Expose database classification feature](https://github.com/prisma/prisma/issues/2424)
- [If a comment is the last line in a model, `prisma format` will move it out of the model](https://github.com/prisma/prisma/issues/2441)
- [Investigate alternatives to required PgBouncer configuration](https://github.com/prisma/prisma/issues/2453)
- [Overwriting database connection string in `Prisma Client` does not work](https://github.com/prisma/prisma/issues/2510)
- [PgBouncer mode](https://github.com/prisma/prisma/issues/2520)
- [Documentation parsed from doc comment is missing for enums](https://github.com/prisma/prisma/issues/2549)
`prisma-client-js`
- [Document `forceTransactions` / pgBouncer](https://github.com/prisma/prisma-client-js/issues/503)
- [Better instructions on Query Engine panic](https://github.com/prisma/prisma-client-js/issues/610)
- [Ability to use Heroku's pgbouncer](https://github.com/prisma/prisma-client-js/issues/628)
- [Prisma Client failing with PgBouncer Transaction Mode](https://github.com/prisma/prisma-client-js/issues/651)
- [Basic reporting capability for runtime errors in Client ](https://github.com/prisma/prisma-client-js/issues/661)
- [Prisma Client Beta 4 broken with Netlify](https://github.com/prisma/prisma-client-js/issues/672)
- [PANIC error on upsert query](https://github.com/prisma/prisma-client-js/issues/683)
- [Cannot use prisma.create() with nullable field set to null](https://github.com/prisma/prisma-client-js/issues/699)
`vscode`
- [Trailing comments are broken to the next line when formatting](https://github.com/prisma/vscode/issues/3)
- [Recognize Prisma1 schemas and tell user to install the other extension and rename file](https://github.com/prisma/vscode/issues/43)
- [Allow inline comment](https://github.com/prisma/vscode/issues/72)
- [Formatting moves comment from inside model to above model](https://github.com/prisma/vscode/issues/83)
- [Preserve newlines / whitespaces inside models](https://github.com/prisma/vscode/issues/88)
- [Extension deletes unused commented out models](https://github.com/prisma/vscode/issues/89)
- [Use same versioning scheme & release cadence as Prisma itself](https://github.com/prisma/vscode/issues/93)
- [prisma-fmt: add newline in the end of the file](https://github.com/prisma/vscode/issues/97)
- [Triple slash comments in prisma schema file not working](https://github.com/prisma/vscode/issues/104)
- [Versioning scheme](https://github.com/prisma/vscode/issues/121)
- [Add badges and repo explanation to README](https://github.com/prisma/vscode/issues/135)
- [VSCode extension errors when linting .prisma file](https://github.com/prisma/vscode/issues/140)
- [Also output extension name / package and version on startup](https://github.com/prisma/vscode/issues/141)
- [Configuring Git to handle line endings](https://github.com/prisma/vscode/issues/146)
- [Remove Prisma as Icon Theme](https://github.com/prisma/vscode/issues/155)
`prisma-engines`
- [Improve a model's default value in the AST](https://github.com/prisma/prisma-engines/issues/723)
Credits
Huge thanks to Sytten, thankwsx, zachasme for helping!