Change db_uri to hand out UTF8 MySQL URIs

MySQL databases normally default to use whatever
character set is read from the global config.
OpenStack projects expect to be working with a unicode
charset database, so lets make sure that assumption is
true by explicitly stating UTF8 in the connection string.

Closes-Bug: 1257056

Change-Id: Iac63b40f603d1144ae3c6575b372ad586dabd4b9
This commit is contained in:
Mathew Odden 2013-12-02 17:57:53 -06:00
parent 2af3fafcc3
commit 0eead56b69
4 changed files with 9 additions and 3 deletions

View File

@ -2,6 +2,10 @@
This file is used to list changes made in each version of cookbook-openstack-common.
## 0.4.7:
### Bug
* Change `#db_uri` to hand out UTF8 MySQL URIs; i.e. append '?charset=utf8' to mysql URIs
## 0.4.6:
### Bug
* Ensuring `#db_uri` returns a valid sqlite connection string

View File

@ -65,8 +65,10 @@ module ::Openstack
type = "postgresql"
end
case type
when "mysql", "postgresql"
when "postgresql"
result = "#{type}://#{user}:#{pass}@#{host}:#{port}/#{name}"
when "mysql"
result = "#{type}://#{user}:#{pass}@#{host}:#{port}/#{name}?charset=utf8"
when "sqlite"
# SQLite uses filepaths not db name
# README(galstrom): 3 slashes is a relative path, 4 slashes is an absolute path

View File

@ -4,7 +4,7 @@ maintainer_email "cookbooks@lists.tfoundry.com"
license "Apache 2.0"
description "Common OpenStack attributes, libraries and recipes."
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.4.6"
version "0.4.7"
recipe "openstack-common", "Installs/Configures common recipes"
recipe "openstack-common::set_endpoints_by_interface", "Set endpoints by interface"

View File

@ -155,7 +155,7 @@ describe ::Openstack do
end
it "returns db info hash when service found" do
@subject.stub(:node).and_return @chef_run.node
expect = "mysql://user:pass@127.0.0.1:3306/nova"
expect = "mysql://user:pass@127.0.0.1:3306/nova?charset=utf8"
@subject.db_uri("compute", "user", "pass").should == expect
end
end