rusackas commented on code in PR #42312:
URL: https://github.com/apache/superset/pull/42312#discussion_r3651451259
##########
superset/db_engine_specs/postgres.py:
##########
@@ -793,6 +793,28 @@ def get_catalog_names(
)
}
+ @classmethod
+ def get_schema_names(cls, inspector: Inspector) -> set[str]:
+ """
+ Return all schema names, excluding actual Postgres system schemas.
+
+ SQLAlchemy's Postgres dialect filters out system schemas with the
+ query ``nspname NOT LIKE 'pg_%'``. Since ``_`` is a single-character
+ wildcard in SQL ``LIKE`` patterns, this unintentionally excludes any
+ user-defined schema that merely starts with ``pg`` followed by any
+ other character (e.g. ``pgsql``, ``pgstats``), not only the actual
+ Postgres system schemas, which are always prefixed with the literal
+ string ``pg_`` (e.g. ``pg_catalog``, ``pg_toast``).
+ """
Review Comment:
Good catch — reworded so it says it excludes the `pg_`-prefixed system
schemas rather than implying all system schemas start with `pg_`.
##########
tests/unit_tests/db_engine_specs/test_postgres.py:
##########
@@ -403,3 +403,33 @@ def test_interval_type_mutator() -> None:
assert mutator(True) is None
assert mutator([1, 2, 3]) is None
assert mutator({"days": 1}) is None
+
+
+def test_get_schema_names_excludes_only_actual_system_schemas(
+ mocker: MockerFixture,
+) -> None:
+ """
+ DB Eng Specs (postgres): Test ``get_schema_names``
+
+ User-defined schemas that merely start with ``pg`` (but are not
+ actual Postgres system schemas, which always start with the literal
+ ``pg_``) must not be filtered out. See SIP/issue #30678.
+ """
Review Comment:
Fixed — dropped the SIP wording, it just references issue #30678 now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]