Skip to content

Commit

Permalink
Merge pull request #565 from mmonaco/master
Browse files Browse the repository at this point in the history
mysql_database: prevent syntax error with collate=>'binary'
  • Loading branch information
igalic committed Sep 16, 2014
2 parents fbef97d + d986a87 commit 86c7fcf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/puppet/provider/mysql_database/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def self.prefetch(resources)
end

def create
mysql([defaults_file, '-NBe', "create database if not exists `#{@resource[:name]}` character set #{@resource[:charset]} collate #{@resource[:collate]}"].compact)
mysql([defaults_file, '-NBe', "create database if not exists `#{@resource[:name]}` character set `#{@resource[:charset]}` collate `#{@resource[:collate]}`"].compact)

@property_hash[:ensure] = :present
@property_hash[:charset] = @resource[:charset]
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/puppet/provider/mysql_database/mysql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

describe 'create' do
it 'makes a database' do
provider.expects(:mysql).with([defaults_file, '-NBe', "create database if not exists `#{resource[:name]}` character set #{resource[:charset]} collate #{resource[:collate]}"])
provider.expects(:mysql).with([defaults_file, '-NBe', "create database if not exists `#{resource[:name]}` character set `#{resource[:charset]}` collate `#{resource[:collate]}`"])
provider.expects(:exists?).returns(true)
expect(provider.create).to be_truthy
end
Expand Down
5 changes: 5 additions & 0 deletions tests/mysql_database.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@
ensure => present,
charset => 'latin1',
}
database{ 'test5':
ensure => present,
charset => 'binary',
collate => 'binary',
}

0 comments on commit 86c7fcf

Please sign in to comment.