Archived
1
0
Fork 0

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" rolname = '" ,name "')) as not_exists;\n"
"\\gset\n" "\\gset\n"
"\\if :not_exists\n" "\\if :not_exists\n"
"CREATE ROLE " ,name "CREATE ROLE \"" ,name "\""
" WITH " ,(format-permissions permissions) " WITH " ,(format-permissions permissions)
";\n" ";\n"
,@(if create-database? ,@(if create-database?
`("CREATE DATABASE " ,name `("CREATE DATABASE \"" ,name "\""
" OWNER " ,name ";\n") " OWNER \"" ,name "\";\n")
'()) '())
"\\endif\n"))) "\\endif\n")))
roles))) roles)))