diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index e15f57b..cfddb93 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -3151,10 +3151,11 @@ function _registry_check_code($type, $name = NULL) {
   // This function may get called when the default database is not active, but
   // there is no reason we'd ever want to not use the default database for
   // this query.
-  $file = Database::getConnection('default', 'default')->query("SELECT filename FROM {registry} WHERE name = :name AND type = :type", array(
-      ':name' => $name,
-      ':type' => $type,
-    ))
+  $file = db_select('registry', 'r', array('target' => 'default'))
+    ->fields('r', array('filename'))
+    ->condition('r.name', db_like($name), 'LIKE')
+    ->condition('r.type', $type)
+    ->execute()
     ->fetchField();
 
   // Flag that we've run a lookup query and need to update the cache.
diff --git a/modules/simpletest/tests/bootstrap.test b/modules/simpletest/tests/bootstrap.test
index 5dcde32..e4f4743 100644
--- a/modules/simpletest/tests/bootstrap.test
+++ b/modules/simpletest/tests/bootstrap.test
@@ -287,6 +287,35 @@ class BootstrapVariableTestCase extends DrupalWebTestCase {
 }
 
 /**
+ * Test code registry.
+ */
+class BootstrapAutoloadTestCase extends DrupalWebTestCase {
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Code registry',
+      'description' => 'Test that the code registry functions correctly.',
+      'group' => 'Bootstrap'
+    );
+  }
+
+  function setUp() {
+    parent::setUp('drupal_autoload_test');
+  }
+
+  /**
+   * Tests that autoloader name matching is not case sensitive.
+   */
+  function testAutoloadCase() {
+    // Test interface autoloader.
+    $this->assertTrue(drupal_autoload_interface('drupalautoloadtestinterface'), 'drupal_autoload_interface() recognizes <em>DrupalAutoloadTestInterface</em> in lower case.');
+    // Test class autoloader.
+    $this->assertTrue(drupal_autoload_class('drupalautoloadtestclass'), 'drupal_autoload_class() recognizes <em>DrupalAutoloadTestClass</em> in lower case.');
+  }
+
+}
+
+/**
  * Test hook_boot() and hook_exit().
  */
 class HookBootExitTestCase extends DrupalWebTestCase {
