Skip to content

Commit ce53029

Browse files
committed
add missingn table types to Postgres platform [closes #164]
1 parent aaa8e94 commit ce53029

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Platforms/PostgreSqlPlatform.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public function getName(): string
4747
/** @inheritDoc */
4848
public function getTables(?string $schema = null): array
4949
{
50+
// relkind options:
51+
// r = ordinary table, i = index, S = sequence, t = TOAST table, v = view, m = materialized view, c = composite type, f = foreign table, p = partitioned table, I = partitioned index
5052
$result = $this->connection->query(/** @lang GenericSQL */ "
5153
SELECT
5254
DISTINCT ON (c.relname)
@@ -57,7 +59,7 @@ public function getTables(?string $schema = null): array
5759
pg_catalog.pg_class AS c
5860
JOIN pg_catalog.pg_namespace AS n ON n.oid = c.relnamespace
5961
WHERE
60-
c.relkind IN ('r', 'v')
62+
c.relkind IN ('r', 'v', 'm', 'f', 'p')
6163
AND n.nspname = ANY (
6264
CASE %?s IS NULL WHEN true THEN pg_catalog.current_schemas(FALSE) ELSE ARRAY[[%?s]] END
6365
)
@@ -103,7 +105,7 @@ public function getColumns(string $table, ?string $schema = null): array
103105
LEFT JOIN pg_catalog.pg_attrdef AS ad ON ad.adrelid = c.oid AND ad.adnum = a.attnum
104106
LEFT JOIN pg_catalog.pg_constraint AS co ON co.connamespace = c.relnamespace AND contype = 'p' AND co.conrelid = c.oid AND a.attnum = ANY(co.conkey)
105107
WHERE
106-
c.relkind IN ('r', 'v')
108+
c.relkind IN ('r', 'v', 'm', 'f', 'p')
107109
") . (
108110
count($tableArgs) > 1
109111
? "AND c.oid = '%table.%table'::regclass"

0 commit comments

Comments
 (0)