Skip to content
This repository has been archived by the owner on Apr 7, 2018. It is now read-only.

Commit

Permalink
Merge pull request #132 from dtsosie/pgsql-repl-keyword-fix
Browse files Browse the repository at this point in the history
[COOK-4555] #127 Adding db user fails and replication support
  • Loading branch information
kisoku committed Feb 22, 2015
2 parents 384751f + 7d249d6 commit f5e500f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions libraries/provider_database_postgresql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ def exists?
ret
end

# Test if text is psql keyword
def keyword?(text)
begin
result = db('template1').exec_params('select * from pg_get_keywords() where word = $1', [text.downcase]).num_tuples != 0
ensure
close
end
result
end

#
# Specifying the database in the connection parameter for the postgres resource is not recommended.
#
Expand Down
2 changes: 1 addition & 1 deletion libraries/provider_database_postgresql_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def action_create
options += " #{@new_resource.createdb ? 'CREATEDB' : 'NOCREATEDB'}"
options += " #{@new_resource.createrole ? 'CREATEROLE' : 'NOCREATEROLE'}"
options += " #{@new_resource.login ? 'LOGIN' : 'NOLOGIN'}"
options += " #{@new_resource.replication ? 'REPLICATION' : 'NOREPLICATION'}"
options += " #{@new_resource.replication ? 'REPLICATION' : 'NOREPLICATION'}" if keyword?('REPLICATION')
options += " #{@new_resource.superuser ? 'SUPERUSER' : 'NOSUPERUSER'}"

statement = "CREATE USER \"#{@new_resource.username}\""
Expand Down

0 comments on commit f5e500f

Please sign in to comment.