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`.
This commit is contained in:
Sasha
2024-11-06 20:29:57 +02:00
committed by GitHub
parent f507305192
commit 147d28e62c

View File

@@ -61,7 +61,7 @@ export const createDatabase = async function (this: BasePostgresAdapter, args: A
try {
await managementClient.connect()
await managementClient.query(`CREATE DATABASE ${dbName}`)
await managementClient.query(`CREATE DATABASE "${dbName}"`)
this.payload.logger.info(`Created database "${dbName}"`)