mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge pull request #92 from simonwelsh/fulltextsearch-fix
BUGFIX fulltext fixes.
This commit is contained in:
commit
3c16af3aca
@ -259,10 +259,24 @@ class MySQLDatabase extends SS_Database {
|
||||
$alterList[] .= "ADD ". $this->getIndexSqlDefinition($k, $v);
|
||||
}
|
||||
|
||||
$alterations = implode(",\n", $alterList);
|
||||
$this->query("ALTER TABLE \"$tableName\" $alterations");
|
||||
|
||||
if($alteredOptions && isset($alteredOptions[get_class($this)])) {
|
||||
if(!isset($this->indexList[$tableName])) {
|
||||
$this->indexList[$tableName] = $this->indexList($tableName);
|
||||
}
|
||||
|
||||
$skip = false;
|
||||
foreach($this->indexList[$tableName] as $index) {
|
||||
if(strpos($index, 'fulltext ') === 0) {
|
||||
$skip = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($skip) {
|
||||
DB::alteration_message(
|
||||
sprintf("Table %s options not changed to %s due to fulltextsearch index", $tableName, $alteredOptions[get_class($this)]),
|
||||
"changed"
|
||||
);
|
||||
} else {
|
||||
$this->query(sprintf("ALTER TABLE \"%s\" %s", $tableName, $alteredOptions[get_class($this)]));
|
||||
DB::alteration_message(
|
||||
sprintf("Table %s options changed: %s", $tableName, $alteredOptions[get_class($this)]),
|
||||
@ -271,6 +285,10 @@ class MySQLDatabase extends SS_Database {
|
||||
}
|
||||
}
|
||||
|
||||
$alterations = implode(",\n", $alterList);
|
||||
$this->query("ALTER TABLE \"$tableName\" $alterations");
|
||||
}
|
||||
|
||||
public function isView($tableName) {
|
||||
$info = $this->query("SHOW /*!50002 FULL*/ TABLES LIKE '$tableName'")->record();
|
||||
return $info && strtoupper($info['Table_type']) == 'VIEW';
|
||||
|
@ -49,6 +49,9 @@ class FulltextSearchable extends DataExtension {
|
||||
if(!class_exists($class)) continue;
|
||||
|
||||
if(isset($defaultColumns[$class])) {
|
||||
if(DB::getConn()->getDatabaseServer() == 'mysql') {
|
||||
Object::add_static_var($class, 'create_table_options', array('MySQLDatabase' => 'ENGINE=MyISAM'), true);
|
||||
}
|
||||
Object::add_extension($class, "FulltextSearchable('{$defaultColumns[$class]}')");
|
||||
Object::add_static_var($class, 'create_table_options', array('MySQLDatabase' => 'ENGINE=MyISAM'));
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user