ashb commented on code in PR #48547:
URL: https://github.com/apache/airflow/pull/48547#discussion_r2044426348
##########
airflow-core/src/airflow/models/variable.py:
##########
@@ -231,8 +232,63 @@ def set(
ctx = create_session()
with ctx as session:
- Variable.delete(key, session=session)
- session.add(Variable(key=key, val=stored_value,
description=description))
+ new_variable = Variable(key=key, val=stored_value,
description=description)
+
+ # Perform dialect-specific upsert operation
+ dialect_name = session.get_bind().dialect.name
+
+ # Map of dialect names to their corresponding module paths
+ dialect_insert_map = {
+ "postgresql": "sqlalchemy.dialects.postgresql.insert",
+ "mysql": "sqlalchemy.dialects.mysql.insert",
+ "sqlite": "sqlalchemy.dialects.sqlite.insert",
+ }
Review Comment:
This honestly is a bit overkill, and using string imports hides some
references.
I'd suggest doing something like this
https://github.com/apache/airflow/blob/6ced7b86d430c8ceafbb27502ce467fccf23c7fa/airflow-core/src/airflow/dag_processing/collection.py#L679-L692
(note we don't need the `else` -- we explicitly only support Postgresql, MySQL
and SQLite.
--
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]