Skip to content

Commit 147d28e

Browse files
authored
fix(db-postgres): handle special characters in createDatabase (#9022)
### What? Handles database name with special characters. For example: `-` - `my-awesome-app`. ### Why? Previously, `my-awesome-app` led to this error: ``` Error: failed to create database my-awesome-app. Details: syntax error at or near "-" ``` This can reproduced for example with `create-payload-app`, as the generated db name is based on project's name. ### How? Wraps the query variable to quotes, `create database "my-awesome-app"` instead of `create database my-awesome-app`.
1 parent f507305 commit 147d28e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/drizzle/src/postgres/createDatabase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const createDatabase = async function (this: BasePostgresAdapter, args: A
6161

6262
try {
6363
await managementClient.connect()
64-
await managementClient.query(`CREATE DATABASE ${dbName}`)
64+
await managementClient.query(`CREATE DATABASE "${dbName}"`)
6565

6666
this.payload.logger.info(`Created database "${dbName}"`)
6767

0 commit comments

Comments
 (0)