Skip to content

Commit

Permalink
permit storage of UTF-8 chars in MySQL DB (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson authored Aug 5, 2024
1 parent 25cb7c1 commit c535e13
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- Permit storage of UTF-8 chars in MySQL DB, related to #190

### 1.20240313

- Fix error email sent when reports are too large
Expand Down
5 changes: 4 additions & 1 deletion lib/Mail/DMARC/Report/Store/SQL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,8 @@ sub db_connect {
my $needs_tables;

$self->{grammar} = undef;
my %opts;

if ($dsn =~ /sqlite/i) {
my ($db) = ( split /=/, $dsn )[-1];
if ( !$db || $db eq ':memory:' || !-e $db ) {
Expand All @@ -541,14 +543,15 @@ sub db_connect {
}
$self->{grammar} = Mail::DMARC::Report::Store::SQL::Grammars::SQLite->new();
} elsif ($dsn =~ /mysql/i) {
$opts{'mysql_enable_utf8mb4'} = 1;
$self->{grammar} = Mail::DMARC::Report::Store::SQL::Grammars::MySQL->new();
} elsif ($dsn =~ /pg/i) {
$self->{grammar} = Mail::DMARC::Report::Store::SQL::Grammars::PostgreSQL->new();
} else {
croak "can't determine database type, so unable to load grammar.\n";
}

$self->{dbix} = DBIx::Simple->connect( $dsn, $user, $pass )
$self->{dbix} = DBIx::Simple->connect( $dsn, $user, $pass, \%opts )
or return $self->error( DBIx::Simple->error );

if ($needs_tables) {
Expand Down

0 comments on commit c535e13

Please sign in to comment.