pierrejeambrun commented on code in PR #60008:
URL: https://github.com/apache/airflow/pull/60008#discussion_r2691433739
##########
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:
Yeah the dialect thing is a problem. Lets not delay because of a test, just
to be sure I added a test case to dag that is actually using a OR search, just
to be sure.
We can always improve later.
--
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]