Jkhall81 commented on code in PR #60008:
URL: https://github.com/apache/airflow/pull/60008#discussion_r2656353774
##########
airflow-core/tests/unit/api_fastapi/common/test_parameters.py:
##########
@@ -99,3 +100,26 @@ def test_sort_param_max_number_of_filers(self):
),
):
param.to_orm(None)
+
+
+class TestSearchParam:
+ def test_to_orm_single_value(self):
+ """Test search with a single term."""
+ param = _SearchParam(DagModel.dag_id).set_value("example_bash")
+ statement = select(DagModel)
+ statement = param.to_orm(statement)
+
+ sql = str(statement.compile(compile_kwargs={"literal_binds":
True})).lower()
+ assert "dag_id" in sql
+ assert "like" in sql
+
+ def test_to_orm_multiple_values_or(self):
+ """Test search with multiple terms using the pipe | operator."""
+ param = _SearchParam(DagModel.dag_id).set_value("example_bash |
example_python")
+ statement = select(DagModel)
+ statement = param.to_orm(statement)
+
+ sql = str(statement.compile(compile_kwargs={"literal_binds": True}))
+ assert "OR" in sql
+ assert "example_bash" in sql
+ assert "example_python" in sql
Review Comment:
Thanks for the suggestion! I went with the keyword assertions because I
thought asserting the full compiled SQL string might make the test brittle /
requre maintenance in the future. If the SQLAlchemy version changes its
formatting or if we run tests against different DB dialects, then a hardcoded
string could cause failures. By checking for the presence of the `OR` operator
and the specific search terms used, we can verify the logic and keep the test
robust. What do you think?
--
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]