Skip to content

Commit

Permalink
Add introspection for unlogged PostgreSQL tables
Browse files Browse the repository at this point in the history
  • Loading branch information
f-lombardo committed Jun 6, 2023
1 parent 5402a56 commit 3378413
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Schema/PostgreSQLSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ protected function fetchTableOptionsByTable(string $databaseName, ?string $table
{
$sql = <<<'SQL'
SELECT c.relname,
CASE c.relpersistence WHEN 'u' THEN true ELSE false END as unlogged,
obj_description(c.oid, 'pg_class') AS comment
FROM pg_class c
INNER JOIN pg_namespace n
Expand Down
8 changes: 5 additions & 3 deletions tests/Functional/Driver/DBAL6044Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ public function testUnloggedTables(): void

$schemaManager = $this->connection->createSchemaManager();

$validationSchema = $schemaManager->introspectSchema();
$validationTable = $validationSchema->getTable($unloggedTable->getName());
$this->assertEquals($unloggedTable->getName(), $validationTable->getName());
$validationSchema = $schemaManager->introspectSchema();
$validationUnloggedTable = $validationSchema->getTable($unloggedTable->getName());
$this->assertTrue($validationUnloggedTable->getOption('unlogged'));
$validationLoggedTable = $validationSchema->getTable($loggedTable->getName());
$this->assertFalse($validationLoggedTable->getOption('unlogged'));

$sql = 'SELECT relpersistence FROM pg_class WHERE relname = ?';
$stmt = $this->connection->prepare($sql);
Expand Down

0 comments on commit 3378413

Please sign in to comment.