pierrejeambrun commented on code in PR #48109: URL: https://github.com/apache/airflow/pull/48109#discussion_r2012149189
########## airflow-core/src/airflow/api_fastapi/core_api/services/public/connections.py: ########## @@ -34,6 +34,29 @@ from airflow.models.connection import Connection +def update_orm_from_pydantic( + orm_conn: Connection, pydantic_conn: ConnectionBody, update_mask: list[str] | None = None +): + """Update ORM object from Pydantic object.""" + # Not all fields match and some need setters, therefore copy manually + if not update_mask or "conn_type" in update_mask: + orm_conn.conn_type = pydantic_conn.conn_type + if not update_mask or "description" in update_mask: + orm_conn.description = pydantic_conn.description + if not update_mask or "host" in update_mask: + orm_conn.host = pydantic_conn.host + if not update_mask or "schema" in update_mask: + orm_conn.schema = pydantic_conn.schema_ + if not update_mask or "login" in update_mask: + orm_conn.login = pydantic_conn.login + if not update_mask or "password" in update_mask: + orm_conn.set_password(pydantic_conn.password) + if not update_mask or "port" in update_mask: + orm_conn.port = pydantic_conn.port + if not update_mask or "extra" in update_mask: + orm_conn.set_extra(pydantic_conn.extra) Review Comment: I think the `setter` part is fine to do manually like this. Aliasing part should leverage pydantic aliases idealy. -- 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]
