#838992: set NO_AUTO_VALUE_ON_ZERO so that MySQL stops its silliness with autoincrement columns.

From: Damien Tournoud <damien@commerceguys.com>


---
 database/mysql/database.inc   |    2 +-
 simpletest/simpletest.install |    2 +-
 simpletest/simpletest.module  |    8 ++++++--
 run-tests.sh                  |    8 +++++++-
 4 files changed, 15 insertions(+), 5 deletions(-)

diff --git includes/database/mysql/database.inc includes/database/mysql/database.inc
index bddeb07..5ba605d 100644
--- includes/database/mysql/database.inc
+++ includes/database/mysql/database.inc
@@ -55,7 +55,7 @@ class DatabaseConnection_mysql extends DatabaseConnection {
     // kinds of database systems. These settings force MySQL to behave
     // the same as postgresql, or sqlite in regards to syntax interpretation
     // and invalid data handling. See http://drupal.org/node/344575 for further discussion.
-    $this->exec("SET sql_mode='ANSI,TRADITIONAL'");
+    $this->exec("SET sql_mode='ANSI,TRADITIONAL,NO_AUTO_VALUE_ON_ZERO'");
   }
 
   public function queryRange($query, $from, $count, array $args = array(), array $options = array()) {
diff --git modules/simpletest/simpletest.install modules/simpletest/simpletest.install
index 2805a9d..db6e5f8 100644
--- modules/simpletest/simpletest.install
+++ modules/simpletest/simpletest.install
@@ -152,7 +152,7 @@ function simpletest_schema() {
     'description' => 'Stores simpletest test IDs, used to auto-incrament the test ID so that a fresh test ID is used.',
     'fields' => array(
       'test_id'  => array(
-        'type' => 'serial',
+        'type' => 'int',
         'not null' => TRUE,
         'description' => 'Primary Key: Unique simpletest ID used to group test results together. Each time a set of tests
                             are run a new test ID is used.',
diff --git modules/simpletest/simpletest.module modules/simpletest/simpletest.module
index 228a1df..83e3931 100644
--- modules/simpletest/simpletest.module
+++ modules/simpletest/simpletest.module
@@ -139,8 +139,12 @@ function _simpletest_format_summary_line($summary) {
  */
 function simpletest_run_tests($test_list, $reporter = 'drupal') {
   cache_clear_all();
-  $test_id = db_insert('simpletest_test_id')
-    ->useDefaults(array('test_id'))
+  $test_id = db_next_id();
+  db_insert('simpletest_test_id')
+    ->fields(array('test_id'))
+    ->values(array(
+      'test_id' => $test_id,
+    ))
     ->execute();
 
   // Clear out the previous verbose files.
diff --git scripts/run-tests.sh scripts/run-tests.sh
index 748fbbe..e2aacda 100755
--- scripts/run-tests.sh
+++ scripts/run-tests.sh
@@ -76,7 +76,13 @@ drupal_set_time_limit(0);
 simpletest_script_reporter_init();
 
 // Setup database for test results.
-$test_id = db_insert('simpletest_test_id')->useDefaults(array('test_id'))->execute();
+$test_id = db_next_id();
+db_insert('simpletest_test_id')
+  ->fields(array('test_id'))
+  ->values(array(
+    'test_id' => $test_id,
+  ))
+  ->execute();
 
 // Execute tests.
 simpletest_script_command($args['concurrency'], $test_id, implode(",", $test_list));
