codeant-ai-for-open-source[bot] commented on code in PR #42312:
URL: https://github.com/apache/superset/pull/42312#discussion_r3651608791


##########
superset/db_engine_specs/postgres.py:
##########
@@ -793,6 +793,29 @@ def get_catalog_names(
                 )
             }
 
+    @classmethod
+    def get_schema_names(cls, inspector: Inspector) -> set[str]:
+        """
+        Return all schema names, excluding the ``pg_``-prefixed Postgres
+        system schemas (e.g. ``pg_catalog``, ``pg_toast``).
+
+        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
+        ``pg_``-prefixed system schemas. Matching on the literal ``pg_``
+        prefix instead keeps those user-defined schemas.
+        """
+        with inspector.engine.connect() as conn:
+            return {
+                name
+                for (name,) in conn.execute(
+                    text("SELECT nspname FROM pg_namespace ORDER BY nspname")
+                )
+                if not name.startswith("pg_")
+            }

Review Comment:
   ✅ **Customized review instruction saved!**
   
   **Instruction:**
   > In PostgreSQL schema metadata handling, retain the `pg_` prefix exclusion 
because regular users cannot create schemas with that prefix; only address 
broader `LIKE` wildcard overmatching for names such as `pgsql` or `pgstats`.
   
   **Applied to:**
     - `superset/db_engine_specs/postgres.py`
   
   ---
   💡 *To manage or update this instruction, visit: [CodeAnt AI 
Settings](https://app.codeant.ai/org/settings/learnings)*



-- 
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]

Reply via email to