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


##########
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:
   I don't think we can even make it deprecated really:
   
   This is in DbAPIHook:
   
   ```python
       def get_conn(self):
           """Returns a connection object"""
           db = self.get_connection(getattr(self, self.conn_name_attr))
           return self.connector.connect(host=db.host, port=db.port, 
username=db.login, schema=db.schema)
   ```
   
   So we need to add a
   
   ```python
       @property
       def schema(self):
           return self.schema
   ```
   
   I think. I can't see how we can do that without breaking anything which uses 
dbapi hook, such as `SQLTableCheckOperator`



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

Reply via email to