You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/09/29 19:44:50 UTC

[GitHub] [airflow] kaxil commented on a diff in pull request #26744: Rename schema to database in PostgresHook

kaxil commented on code in PR #26744:
URL: https://github.com/apache/airflow/pull/26744#discussion_r983958008


##########
airflow/providers/postgres/hooks/postgres.py:
##########
@@ -67,10 +68,18 @@ class PostgresHook(DbApiHook):
     supports_autocommit = True
 
     def __init__(self, *args, **kwargs) -> None:
+        if 'schema' in kwargs:
+            warnings.warn(
+                'The "schema" arg has been renamed to "database" as it contained the database name.'
+                'Please use "database" to set the database name.',
+                DeprecationWarning,
+                stacklevel=2,
+            )
+            kwargs['database'] = kwargs['schema']
         super().__init__(*args, **kwargs)
         self.connection: Connection | None = kwargs.pop("connection", None)
         self.conn: connection = None
-        self.schema: str | None = kwargs.pop("schema", None)
+        self.database: str | None = kwargs.pop("database", None)

Review Comment:
   Thought: Should we add `schema` as property and raise deprecation warning for folks relying on `PostgresHook().schema`? Or we rather give them `AttributeError` as it is wrong anyways?



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org