Database connection not allowing back slash or maybe other of the special characters
See original GitHub issueBug description
I already generated my prisma client and my application was running fine, but now the DB user password changed and it has a lot of special characters, so I escaped them using the corresponding percent-encoding value like this:
(+): %2B (😃: %3A (^): %5E (): %5C note: back slash is not showing inside the parenthesis but is there ($): %24
So my DATABASE_URL looks something like this:
DATABASE_URL="sqlserver://{ipaddress}:1433;database={dbname};user={dbuser};password=AbCdE%2B%3A%5E%5C%24;trusServerCertificate=true;encrypt=DANGER_PLAINTEXT"
Now when I run my application using the updated .env file with the DATABASE_URL, I’m getting the following error: (node:28652) UnhandledPromiseRejectionWarning: Error: Error creating a database connection. (Authentication failed for user dbuser).
Am I doing anything wrong? Please advice.
How to reproduce
- After client was generated successfully with other password
- Change the db user password to a string that contains those characters mentioned in the Bug description
- Update the password in the .env file
- Run the application and see the reported error
Expected behavior
The connection should be successful even if the password has special characters, since they were escaped in the DATABASE_URL.
Prisma information
Prisma schema not releventa other than possibly the initial part:
generator client {
provider = "prisma-client-js"
binaryTargets = ["native"]
}
datasource db {
provider = "sqlserver"
url = env("DATABASE_URL")
}
Environment & setup
- OS: Windows 10
- Database: PostgreSQL
- Node.js version: V14.16.0
Prisma Version
prisma : 3.5.0
@prisma/client : 3.5.0
Current platform : windows
Query Engine (Node-API) : libquery-engine 78a5df6def6943431f4c022e1428dbc3e833cf8e (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Migration Engine : migration-engine-cli 78a5df6def6943431f4c022e1428dbc3e833cf8e (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine : introspection-core 78a5df6def6943431f4c022e1428dbc3e833cf8e (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary : prisma-fmt 78a5df6def6943431f4c022e1428dbc3e833cf8e (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash : 78a5df6def6943431f4c022e1428dbc3e833cf8e
Studio : 0.439.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
@janpio Your comment helped me and I found that for MS SQL Server the solution is to enclose each special character within braces {}. This worked for me. I think it would be good to include that detail in the documentation for MS SQL Server users, since you already have the escaping definition for other database engines. Thank you!
(We are going to rename that label soon, it just means that we have no looked at the issue yet to confirm that is has enough information to reproduce and someone needs to do that and engage further - sorry.)
The note in the docs only refers to PostgreSQL and MySQL, I do not know how to escape in the same way for SQL Server.