|
5 | 5 | use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
|
6 | 6 | use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException;
|
7 | 7 | use Doctrine\DBAL\Platforms\AbstractPlatform;
|
| 8 | +use Doctrine\DBAL\Platforms\PostgreSQL120Platform; |
8 | 9 | use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
|
9 | 10 | use Doctrine\DBAL\Schema\AbstractSchemaManager;
|
10 | 11 | use Doctrine\DBAL\Schema\Comparator;
|
@@ -320,6 +321,35 @@ public function testBooleanDefault(callable $comparatorFactory): void
|
320 | 321 | self::assertFalse($diff);
|
321 | 322 | }
|
322 | 323 |
|
| 324 | + /** |
| 325 | + * @param callable(AbstractSchemaManager):Comparator $comparatorFactory |
| 326 | + * |
| 327 | + * @dataProvider \Doctrine\DBAL\Tests\Functional\Schema\ComparatorTestUtils::comparatorProvider |
| 328 | + */ |
| 329 | + public function testGeneratedColumn(callable $comparatorFactory): void |
| 330 | + { |
| 331 | + $wrappedConnection = $this->connection->getWrappedConnection(); |
| 332 | + if (! $this->connection->getDatabasePlatform() instanceof PostgreSQL120Platform) { |
| 333 | + self::markTestSkipped('Generated columns are not supported in Postgres 11 and earlier'); |
| 334 | + } |
| 335 | + |
| 336 | + $table = new Table('ddc6198_generated_always_as'); |
| 337 | + $table->addColumn('id', Types::INTEGER); |
| 338 | + $table->addColumn( |
| 339 | + 'idIsOdd', |
| 340 | + Types::BOOLEAN, |
| 341 | + ['columnDefinition' => 'boolean GENERATED ALWAYS AS (id % 2 = 1) STORED', 'notNull' => false], |
| 342 | + ); |
| 343 | + |
| 344 | + $this->dropAndCreateTable($table); |
| 345 | + |
| 346 | + $databaseTable = $this->schemaManager->introspectTable($table->getName()); |
| 347 | + |
| 348 | + $diff = $comparatorFactory($this->schemaManager)->diffTable($table, $databaseTable); |
| 349 | + |
| 350 | + self::assertFalse($diff); |
| 351 | + } |
| 352 | + |
323 | 353 | /**
|
324 | 354 | * PostgreSQL stores BINARY columns as BLOB
|
325 | 355 | */
|
|
0 commit comments