Hateburo: kazeburo hatenablog

Operations Engineer / Site Reliability / 運用系小姑 / Perl Monger

DBI->cloneとサブクラス

サブクラスでも問題なしっぽ

% perl -MData::Dumper -MDBIx::Sunny -E 'my $dbh=DBIx::Sunny->connect("dbi:mysql:test"); say ref($dbh); my $dbh2=$dbh->clone; say ref($dbh2); say $dbh2->{mysql_enable_utf8}; say Dumper($dbh2->{private_connect_info})'
DBIx::Sunny::db
DBIx::Sunny::db
1
$VAR1 = [
          'dbi:mysql:test',
          undef,
          undef,
          {
            'mysql_enable_utf8' => 1,
            'ShowErrorStatement' => 1,
            'RaiseError' => 1,
            'AutoInactiveDestroy' => 1,
            'PrintError' => 0
          }
        ];

% perl -MData::Dumper -MDBIx::Sunny -E 'my $dbh=DBIx::Sunny->connect("dbi:mysql:test","","",{root_class=>"DBIx::Sunny"}); say ref($dbh); my $dbh2=$dbh->clone; say ref($dbh2); say $dbh2->{mysql_enable_utf8}; say Dumper($dbh2->{private_connect_info})'
DBIx::Sunny::db
DBIx::Sunny::db
1
$VAR1 = [
          'dbi:mysql:test',
          '',
          '',
          {
            'mysql_enable_utf8' => 1,
            'ShowErrorStatement' => 1,
            'RaiseError' => 1,
            'AutoInactiveDestroy' => 1,
            'PrintError' => 0,
            'root_class' => 'DBIx::Sunny'
          }
        ];