Permalink
Browse files

Fix up TestOfStreamDataMySQLDAO

* Correct ALTER TABLE auto_increment usage
  • Loading branch information...
1 parent 44c6608 commit d4bc967145084993187c28e7b610d5efd5698668 @ginatrapani ginatrapani committed Jan 10, 2014
Showing with 10 additions and 2 deletions.
  1. +1 −1 tests/TestOfStreamDataMySQLDAO.php
  2. +9 −1 webapp/_lib/dao/class.StreamDataMySQLDAO.php
View
2 tests/TestOfStreamDataMySQLDAO.php
@@ -106,6 +106,6 @@ public function testResetID() {
$this->dao->insertStreamData('new content 3');
$this->dao->resetID(); // reset when not empty
$res = $this->dao->retrieveNextItem();
- $this->assertEqual(2, $res[0]);
+ $this->assertNull($res[0]);
}
}
View
10 webapp/_lib/dao/class.StreamDataMySQLDAO.php
@@ -82,7 +82,15 @@ private function deleteItem($id) {
}
public function resetID() {
- $q = "ALTER TABLE #prefix#stream_data auto_increment = 1";
+ /**
+ * Modified this ALTER to TRUNCATE due to not being able to reset auto_increment to 1. As per:
+ * http://dev.mysql.com/doc/refman/5.6/en/alter-table.html
+ * "You cannot reset the counter to a value less than or equal to to the value that is currently in use. For both
+ * InnoDB and MyISAM, if the value is less than or equal to the maximum value currently in the AUTO_INCREMENT
+ * column, the value is reset to the current maximum AUTO_INCREMENT column value plus one."
+ */
+ //$q = "ALTER TABLE #prefix#stream_data auto_increment = 1";
+ $q = "TRUNCATE TABLE #prefix#stream_data";
if ($this->profiler_enabled) { Profiler::setDAOMethod(__METHOD__); }
$ps = $this->execute($q);
}

0 comments on commit d4bc967

Please sign in to comment.