Skip to content
Snippets Groups Projects
Commit 334aec1e authored by Guillaume ROUSSE's avatar Guillaume ROUSSE
Browse files

allow database connection options in configuration

parent bf15cbfa
No related branches found
No related tags found
No related merge requests found
...@@ -58,7 +58,8 @@ AccountManager::DB->register_db( ...@@ -58,7 +58,8 @@ AccountManager::DB->register_db(
database => $configuration->{database}->{name}, database => $configuration->{database}->{name},
host => $configuration->{database}->{host}, host => $configuration->{database}->{host},
password => $configuration->{database}->{password}, password => $configuration->{database}->{password},
username => $configuration->{database}->{username} username => $configuration->{database}->{username},
options => [ split(/, */, $configuration->{database}->{options}) ]
); );
my $db = AccountManager::DB->new(); my $db = AccountManager::DB->new();
... ...
......
...@@ -23,6 +23,7 @@ host = localhost ...@@ -23,6 +23,7 @@ host = localhost
name = idp_account_manager name = idp_account_manager
username = idpadmin username = idpadmin
password = secret password = secret
options = mysql_enable_utf8
[idp] [idp]
scope = my.fqdn scope = my.fqdn
... ...
......
...@@ -96,6 +96,7 @@ sub new { ...@@ -96,6 +96,7 @@ sub new {
host => $self->{configuration}->{database}->{host}, host => $self->{configuration}->{database}->{host},
username => $self->{configuration}->{database}->{username}, username => $self->{configuration}->{database}->{username},
password => $self->{configuration}->{database}->{password}, password => $self->{configuration}->{database}->{password},
options => [ split(/, */, $self->{configuration}->{database}->{options}) ]
); );
} else { } else {
$self->{logger}->fatal( $self->{logger}->fatal(
... ...
......
...@@ -8,7 +8,6 @@ use base 'Rose::DB'; ...@@ -8,7 +8,6 @@ use base 'Rose::DB';
__PACKAGE__->use_private_registry; __PACKAGE__->use_private_registry;
__PACKAGE__->SUPER::register_db ( __PACKAGE__->SUPER::register_db (
connect_options => { AutoCommit => 1, ChopBlanks => 1 },
driver => 'mysql', driver => 'mysql',
host => 'localhost', host => 'localhost',
database => 'fake', database => 'fake',
...@@ -19,8 +18,16 @@ __PACKAGE__->SUPER::register_db ( ...@@ -19,8 +18,16 @@ __PACKAGE__->SUPER::register_db (
sub register_db { sub register_db {
my ($pkg, %args) = @_; my ($pkg, %args) = @_;
my $options = {
AutoCommit => 1,
ChopBlanks => 1,
};
if ($args{options}) {
$options->{$_} = 1 foreach @{$args{options}};
}
__PACKAGE__->SUPER::register_db ( __PACKAGE__->SUPER::register_db (
connect_options => { AutoCommit => 1, ChopBlanks => 1 }, connect_options => $options,
driver => $args{driver}, driver => $args{driver},
host => $args{host}, host => $args{host},
database => $args{database}, database => $args{database},
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment