services: PostgreSQL: Quote database names.

* gnu/services/databases.scm (postgresql-create-roles): Quote the name in
the SQL query so that roles/usernames containing hyphens will work.
This commit is contained in:
Marius Bakke 2021-02-06 15:18:40 +01:00
parent e6554523af
commit 221985ce6b
No known key found for this signature in database
GPG Key ID: A2A06DF2A33A54FA

View File

@ -396,12 +396,12 @@ and stores the database cluster in @var{data-directory}."
rolname = '" ,name "')) as not_exists;\n"
"\\gset\n"
"\\if :not_exists\n"
"CREATE ROLE " ,name
"CREATE ROLE \"" ,name "\""
" WITH " ,(format-permissions permissions)
";\n"
,@(if create-database?
`("CREATE DATABASE " ,name
" OWNER " ,name ";\n")
`("CREATE DATABASE \"" ,name "\""
" OWNER \"" ,name "\";\n")
'())
"\\endif\n")))
roles)))