Commit 83c4402
authored
Fix temporal-sql-tool database creation on postgresql when database name contains hyphen (temporalio#4735)
<!-- Describe what has changed in this PR -->
**What changed?**
Added double quotes around database name in the create database query
for PostgreSQL.
<!-- Tell your future self why have you made these changes -->
**Why?**
The issue has been created on temporal-operator project (see:
alexandrevilain/temporal-operator#402).
When we try to use the `temporal-sql-tool` `create` command with a
database name containing hyphen(s), even if escaped in command, it
throws the following error: `pq: syntax error at or near \"-\"`.
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
**How did you test it?**
Before the fix:
```bash
$ go run ./cmd/tools/sql --endpoint="localhost" --port="5432" --user="temporal-aws-dev" --password="$TEMPORAL_DEFAULT_DATASTORE_PASSWORD" --database="temporal-aws-dev" --plugin="postgres" create
2023-08-05T20:44:58.957+0200 ERROR Unable to create SQL database. {"error": "pq: syntax error at or near \"-\"", "logging-call-at": "handler.go:94"}
exit status 1
```
After the fix:
```bash
$ go run ./cmd/tools/sql --endpoint="localhost" --port="5432" --user="temporal-aws-dev" --password="$TEMPORAL_DEFAULT_DATASTORE_PASSWORD" --database="temporal-aws-dev" --plugin="postgres" create
$ echo $?
0
```
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
**Potential risks**
Nothing.
<!-- Is this PR a hotfix candidate or require that a notification be
sent to the broader community? (Yes/No) -->
**Is hotfix candidate?**
No.1 parent ef49189 commit 83c4402
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
0 commit comments