Dancer-Plugin-Database-Core
view release on metacpan or search on metacpan
lib/Dancer/Plugin/Database/Core.pm view on Meta::CPAN
# If the app is configured to use UTF-8, the user will want text from the
# database in UTF-8 to Just Work, so if we know how to make that happen, do
# so, unless they've set the auto_utf8 plugin setting to a false value.
my $app_charset = $settings->{charset} || "";
my $auto_utf8 = exists $settings->{auto_utf8} ? $settings->{auto_utf8} : 1;
if (lc $app_charset eq 'utf-8' && $auto_utf8) {
# The option to pass to the DBI->connect call depends on the driver:
my %param_for_driver = (
SQLite => 'sqlite_unicode',
mysql => 'mysql_enable_utf8',
Pg => 'pg_enable_utf8',
);
my $param = $param_for_driver{$driver};
if ($param && !$settings->{dbi_params}{$param}) {
$logger->(
debug => "Adding $param to DBI connection params"
. " to enable UTF-8 support"
( run in 0.563 second using v1.01-cache-2.11-cpan-88abd93f124 )