Dev-iL commented on code in PR #60008:
URL: https://github.com/apache/airflow/pull/60008#discussion_r2658793384


##########
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:
   I agree with @Jkhall81's approach and reasoning regarding the sql assertion 
- the exact sql sqlalchemy outputs is an implementation detail, and we 
shouldn't be tied to that on principal.
   
   Let's assume for a second an extreme case where sqla is not deterministic - 
sometimes outputs `A OR B` and sometimes `B OR A`. How would we define the test 
in that case?



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