Commit b17992b5 authored by Steve Müller's avatar Steve Müller

Merge pull request #716 from PowerKiKi/bug-partial-indexes-with-multiple-conditions

Do not TRIM() parentheses around partial indexes conditions

Close #716
parents 9b3ace24 67b2ea55
...@@ -343,7 +343,7 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -343,7 +343,7 @@ class PostgreSqlPlatform extends AbstractPlatform
{ {
return "SELECT quote_ident(relname) as relname, pg_index.indisunique, pg_index.indisprimary, return "SELECT quote_ident(relname) as relname, pg_index.indisunique, pg_index.indisprimary,
pg_index.indkey, pg_index.indrelid, pg_index.indkey, pg_index.indrelid,
TRIM(BOTH '()' FROM pg_get_expr(indpred, indrelid)) AS where pg_get_expr(indpred, indrelid) AS where
FROM pg_class, pg_index FROM pg_class, pg_index
WHERE oid IN ( WHERE oid IN (
SELECT indexrelid SELECT indexrelid
......
...@@ -343,6 +343,37 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -343,6 +343,37 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$this->assertFalse($foundTable, 'View "list_tables_excludes_views_test_view" must not be found in table list'); $this->assertFalse($foundTable, 'View "list_tables_excludes_views_test_view" must not be found in table list');
} }
/**
* @group DBAL-1033
*/
public function testPartialIndexes()
{
$offlineTable = new Schema\Table('person');
$offlineTable->addColumn('id', 'integer');
$offlineTable->addColumn('name', 'string');
$offlineTable->addColumn('email', 'string');
$offlineTable->addUniqueIndex(array('id', 'name'), 'simple_partial_index', array('where' => '(id IS NULL)'));
$offlineTable->addIndex(array('id', 'name'), 'complex_partial_index', array(), array('where' => '(((id IS NOT NULL) AND (name IS NULL)) AND (email IS NULL))'));
$this->_sm->dropAndCreateTable($offlineTable);
$onlineTable = $this->_sm->listTableDetails('person');
$comparator = new Schema\Comparator();
$this->assertFalse($comparator->diffTable($offlineTable, $onlineTable));
$this->assertTrue($onlineTable->hasIndex('simple_partial_index'));
$this->assertTrue($onlineTable->hasIndex('complex_partial_index'));
$this->assertTrue($onlineTable->getIndex('simple_partial_index')->hasOption('where'));
$this->assertTrue($onlineTable->getIndex('complex_partial_index')->hasOption('where'));
$this->assertSame('(id IS NULL)', $onlineTable->getIndex('simple_partial_index')->getOption('where'));
$this->assertSame(
'(((id IS NOT NULL) AND (name IS NULL)) AND (email IS NULL))',
$onlineTable->getIndex('complex_partial_index')->getOption('where')
);
}
} }
class MoneyType extends Type class MoneyType extends Type
......
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