Skip to content

Commit

Permalink
Fix Truncate Error Issue when using views in a Unittest.
Browse files Browse the repository at this point in the history
When using a view in a SilverStripe project, whenever the tear down scripts for the Unittests are run the following error occurs:

Couldn't run query:
TRUNCATE "ActivityPoints_view"
Table 'ss_tmpdb2391727.ActivityPoints_view' doesn't exist

This was due to the MySQLSchemaManager::tableList() function assuming that all records in the TABLES were actual tables containing data.

This small tweak fixes the issue by modifying the SQL to filter out views from the list before truncating.
  • Loading branch information
PapaBearNZ committed Aug 14, 2017
1 parent 6945179 commit b04a1ab
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion model/connect/MySQLSchemaManager.php
Expand Up @@ -336,7 +336,7 @@ public function indexList($table) {

public function tableList() {
$tables = array();
foreach ($this->query("SHOW TABLES") as $record) {
foreach ($this->query("SHOW FULL TABLES WHERE Table_Type != 'VIEW'") as $record) {
$table = reset($record);
$tables[strtolower($table)] = $table;
}
Expand Down

0 comments on commit b04a1ab

Please sign in to comment.