Revision history for DBIx::Class
+ * Fixes
+ - Disable mysql_auto_reconnect for MySQL - depending on the ENV
+ it sometimes defaults to on and causes major borkage on older
+ DBD::mysql versions
+
0.08127 2011-01-19 16:40 (UTC)
* New Features / Changes
- Schema/resultsource instances are now crossreferenced via a new
$dbh->{mysql_insertid};
}
+# here may seem like an odd place to override, but this is the first
+# method called after we are connected *and* the driver is determined
+# ($self is reblessed). See code flow in ::Storage::DBI::_populate_dbh
+sub _run_connection_actions {
+ my $self = shift;
+
+ # default mysql_auto_reconnect to off unless explicitly set
+ if (
+ $self->_dbh->{mysql_auto_reconnect}
+ and
+ ! exists $self->_dbic_connect_attributes->{mysql_auto_reconnect}
+ ) {
+ $self->_dbh->{mysql_auto_reconnect} = 0;
+ }
+
+ $self->next::method(@_);
+}
+
# we need to figure out what mysql version we're running
sub sql_maker {
my $self = shift;
);
}
-## If find() is the first query after connect()
-## DBI::Storage::sql_maker() will be called before
-## _determine_driver() and so the ::SQLHacks class for MySQL
-## will not be used
-
-my $schema2 = DBICTest::Schema->connect($dsn, $user, $pass);
-$schema2->resultset("Artist")->find(4);
-isa_ok($schema2->storage->sql_maker, 'DBIx::Class::SQLMaker::MySQL');
+# make sure find hooks determine driver
+{
+ my $schema = DBICTest::Schema->connect($dsn, $user, $pass);
+ $schema->resultset("Artist")->find(4);
+ isa_ok($schema->storage->sql_maker, 'DBIx::Class::SQLMaker::MySQL');
+}
+
+# make sure the mysql_auto_reconnect buggery is avoided
+{
+ local $ENV{MOD_PERL} = 'boogiewoogie';
+ my $schema = DBICTest::Schema->connect($dsn, $user, $pass);
+ ok (! $schema->storage->_get_dbh->{mysql_auto_reconnect}, 'mysql_auto_reconnect unset regardless of ENV' );
+
+ my $schema2 = DBICTest::Schema->connect($dsn, $user, $pass, { mysql_auto_reconnect => 1 });
+ ok ($schema2->storage->_get_dbh->{mysql_auto_reconnect}, 'but is properly set if explicitly requested mysql_auto_reconnect' );
+}
done_testing;