Commit 16d2ccfb authored by Jan Sorgalla's avatar Jan Sorgalla

Add reverse engineering part for spatial indexes

parent 9f7c75f2
......@@ -73,6 +73,8 @@ class MySqlSchemaManager extends AbstractSchemaManager
}
if (strpos($v['index_type'], 'FULLTEXT') !== false) {
$v['flags'] = array('FULLTEXT');
} elseif (strpos($v['index_type'], 'SPATIAL') !== false) {
$v['flags'] = array('SPATIAL');
}
$tableIndexes[$k] = $v;
}
......
......@@ -5,11 +5,21 @@ namespace Doctrine\Tests\DBAL\Functional\Schema;
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
require_once __DIR__ . '/../../../TestInit.php';
class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
protected function setUp()
{
parent::setUp();
if (!Type::hasType('point')) {
Type::addType('point', 'Doctrine\Tests\Types\MySqlPointType');
}
}
public function testSwitchPrimaryKeyColumns()
{
$tableOld = new Table("switch_primary_key_columns");
......@@ -66,6 +76,23 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$this->assertTrue($indexes['f_index']->hasFlag('fulltext'));
}
public function testSpatialIndex()
{
$table = new Table('spatial_index');
$table->addColumn('point', 'point');
$table->addIndex(array('point'), 's_index');
$table->addOption('engine', 'MyISAM');
$index = $table->getIndex('s_index');
$index->addFlag('spatial');
$this->_sm->dropAndCreateTable($table);
$indexes = $this->_sm->listTableIndexes('spatial_index');
$this->assertArrayHasKey('s_index', $indexes);
$this->assertTrue($indexes['s_index']->hasFlag('spatial'));
}
/**
* @group DBAL-400
*/
......
<?php
namespace Doctrine\Tests\Types;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;
class MySqlPointType extends Type
{
public function getName()
{
return 'point';
}
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
return strtoupper($this->getName());
}
public function getMappedDatabaseTypes(AbstractPlatform $platform)
{
return array('point');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment