jason810496 commented on code in PR #60008:
URL: https://github.com/apache/airflow/pull/60008#discussion_r2656749021


##########
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:
   > requre maintenance in the future. If the SQLAlchemy version changes its 
formatting 
   
   We didn't bump the SQLAlchemy version that often, so it does't seem to be 
our concern.
   
   >  if we run tests against different DB dialects, then a hardcoded string 
could cause failures.
   
   We could resolve it by dynamically generating `pytest.param` for each 
dialects
   
   e.g. 
https://github.com/apache/airflow/blob/7d5d2c61942dc91ab64b576cb5c9b1b6b0ff7bd6/airflow-core/tests/unit/api_fastapi/common/test_exceptions.py#L128-L156
 ( For `TestUniqueConstraintErrorHandler`, we need to check the returning 
statement in case of showing sensitive value in the response )
   



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