Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sqlit/domains/connections/providers/postgresql/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def get_tables(self, conn: Any, database: str | None = None) -> list[TableInfo]:
cursor = conn.cursor()
cursor.execute(
"SELECT table_schema, table_name FROM information_schema.tables "
"WHERE table_type = 'BASE TABLE' "
"WHERE table_type IN ('BASE TABLE', 'FOREIGN') "
"AND table_schema NOT IN ('pg_catalog', 'information_schema') "
"ORDER BY table_schema, table_name"
)
Expand Down
23 changes: 23 additions & 0 deletions tests/unit/test_postgres_fdw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Regression coverage for PostgreSQL foreign-table discovery."""

from unittest.mock import MagicMock

from sqlit.domains.connections.providers.postgresql.adapter import PostgreSQLAdapter


def test_get_tables_requests_base_and_foreign_tables() -> None:
connection = MagicMock()
cursor = connection.cursor.return_value
cursor.fetchall.return_value = [
("public", "local_users"),
("remote", "foreign_orders"),
]

tables = PostgreSQLAdapter().get_tables(connection)

assert tables == [
("public", "local_users"),
("remote", "foreign_orders"),
]
query = cursor.execute.call_args.args[0]
assert "table_type IN ('BASE TABLE', 'FOREIGN')" in query
Loading