Skip to content

Commit cd31c71

Browse files
committed
Merge pull request puppetlabs#134 from cv/patch-1
Allow SQL commands to be run against a specific DB
2 parents 92023f1 + 6f6da92 commit cd31c71

File tree

1 file changed

+1
-1
lines changed
  • lib/puppet/provider/postgresql_psql

1 file changed

+1
-1
lines changed

lib/puppet/provider/postgresql_psql/ruby.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def run_unless_sql_command(sql)
5151
end
5252

5353
def run_sql_command(sql)
54-
command = 'psql -t -c "' << sql.gsub('"', '\"') << '"'
54+
command = %{psql #{"-d #{resource[:db]}" if resource[:db]} -t -c "#{sql.gsub('"', '\"')}"}
5555
if resource[:cwd]
5656
Dir.chdir resource[:cwd] do
5757
Puppet::Util::SUIDManager.run_and_capture(command, resource[:psql_user], resource[:psql_group])

0 commit comments

Comments
 (0)