Merge branch 'master' into 'master'

__postgres_*: use delimited identifiers (double quoted) in generated SQL

See merge request ungleich-public/cdist!826
remotes/origin/feature/info-command
Darko Poljak 5 years ago
commit c51571b47f
  1. 6
      cdist/conf/type/__postgres_database/gencode-remote
  2. 2
      cdist/conf/type/__postgres_role/gencode-remote

@ -41,12 +41,12 @@ if [ "$state_should" != "$state_is" ]; then
present)
owner=""
if [ -f "$__object/parameter/owner" ]; then
owner="-O '$(cat "$__object/parameter/owner")'"
owner="-O \"$(cat "$__object/parameter/owner")\""
fi
echo "su - '$postgres_user' -c \"createdb $owner '$name'\""
echo "su - '$postgres_user' -c \"createdb $owner \"$name\"\""
;;
absent)
echo "su - '$postgres_user' -c \"dropdb '$name'\""
echo "su - '$postgres_user' -c \"dropdb \"$name\"\""
;;
esac
fi

@ -54,7 +54,7 @@ case "$state_should" in
[ -n "$password" ] && password="PASSWORD '$password'"
cmd="CREATE ROLE $name WITH $password $booleans"
cmd="CREATE ROLE \"$name\" WITH $password $booleans"
echo "su - '$postgres_user' -c \"psql postgres -wc \\\"$cmd\\\"\""
;;
absent)

Loading…
Cancel
Save