Permalink
Browse files

Accept a single string as on_connect_do value.

Seems un-DWIMmish to insist on being provided an arrayref even if there's only
one statement to run, so accept a straightforward string, too.

e.g.:

  on_connect_do: "SET SQL_MODE='TRADITIONAL'"
  • Loading branch information...
1 parent aa3c180 commit 93b4eeae04d360b36cb655ba462ca8b2699feacc @bigpresh committed May 14, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/Dancer/Plugin/Database.pm
View
5 lib/Dancer/Plugin/Database.pm
@@ -194,7 +194,10 @@ sub _get_connection {
);
return;
} elsif (exists $settings->{on_connect_do}) {
- for (@{ $settings->{on_connect_do} }) {
+ my $to_do = ref $settings->{on_connect_do} eq 'ARRAY'
+ ? $settings->{on_connect_do}
+ : [ $settings->{on_connect_do} ];
+ for (@$to_do) {
$dbh->do($_) or Dancer::Logger::error(
"Failed to perform on-connect command $_"
);

0 comments on commit 93b4eea

Please sign in to comment.