|
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;
|
@@ -334,6 +335,35 @@ public function testBooleanDefault(callable $comparatorFactory): void
|
334 | 335 | self::assertFalse($diff);
|
335 | 336 | }
|
336 | 337 |
|
| 338 | + /** |
| 339 | + * @param callable(AbstractSchemaManager):Comparator $comparatorFactory |
| 340 | + * |
| 341 | + * @dataProvider \Doctrine\DBAL\Tests\Functional\Schema\ComparatorTestUtils::comparatorProvider |
| 342 | + */ |
| 343 | + public function testGeneratedColumn(callable $comparatorFactory): void |
| 344 | + { |
| 345 | + $wrappedConnection = $this->connection->getWrappedConnection(); |
| 346 | + if (! $this->connection->getDatabasePlatform() instanceof PostgreSQL120Platform) { |
| 347 | + self::markTestSkipped('Generated columns are not supported in Postgres 11 and earlier'); |
| 348 | + } |
| 349 | + |
| 350 | + $table = new Table('ddc6198_generated_always_as'); |
| 351 | + $table->addColumn('id', Types::INTEGER); |
| 352 | + $table->addColumn( |
| 353 | + 'idIsOdd', |
| 354 | + Types::BOOLEAN, |
| 355 | + ['columnDefinition' => 'boolean GENERATED ALWAYS AS (id % 2 = 1) STORED', 'notNull' => false], |
| 356 | + ); |
| 357 | + |
| 358 | + $this->dropAndCreateTable($table); |
| 359 | + |
| 360 | + $databaseTable = $this->schemaManager->introspectTable($table->getName()); |
| 361 | + |
| 362 | + $diff = $comparatorFactory($this->schemaManager)->diffTable($table, $databaseTable); |
| 363 | + |
| 364 | + self::assertFalse($diff); |
| 365 | + } |
| 366 | + |
337 | 367 | /**
|
338 | 368 | * PostgreSQL stores BINARY columns as BLOB
|
339 | 369 | */
|
|
0 commit comments