[Dbix-class] Monkey-patching around a MySQL/UTF8 bug
Hailin Hu
i at h2l.name
Thu Feb 26 14:53:49 GMT 2015
Give a try to connect with the option mysql_enable_utf8 = 1
http://search.cpan.org/~capttofu/DBD-mysql-4.029/lib/DBD/mysql.pm#DATABASE_HANDLES
On Thu, Feb 26, 2015 at 11:43 PM, David Cantrell <david at cantrell.org.uk> wrote:
> This bug in DBD::mysql is apparently not going to be fixed:
> https://rt.cpan.org/Ticket/Display.html?id=60987
>
> and it's preventing us from inserting, eg, an i-acute character into our
> database. Our customer Mr. GarcÃa is Quite Irritated at this. It appears
> that any non-ASCII character with code-point below 0x100 is affected
> (higher codepoints like ij and ψ and ☃ are OK). As a work-around I've
> done this in my application:
>
> BEGIN {
> my $old_ex = \&DBIx::Class::Storage::DBI::_dbh_execute;
> my $new_ex = sub {
> foreach (@{$_[3]}) {
> if(exists($_->[1]) && defined($_->[1])) {
> utf8::upgrade($_->[1])
> }
> }
> return $old_ex->(@_);
> };
>
> {
> no strict qw/ refs /;
> no warnings 'redefine';
> *DBIx::Class::Storage::DBI::_dbh_execute = $new_ex;
> }
> }
>
> And it appears to work. However, I don't like monkey-patching like that.
> Is there a better way that I haven't been able to find in the
> DBIx::Class doco?
>
> --
> David Cantrell | Hero of the Information Age
>
> Sobol's Law of Telecom Utilities:
> Telcos are malicious; cablecos are simply clueless.
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
More information about the DBIx-Class
mailing list