pierrejeambrun commented on code in PR #45420:
URL: https://github.com/apache/airflow/pull/45420#discussion_r1906850451


##########
airflow/api_fastapi/common/parameters.py:
##########
@@ -324,21 +328,34 @@ def depends_filter(value: T | None = query) -> 
FilterParam[T | None]:
     return depends_filter
 
 
-class _TagsFilter(BaseParam[list[str]]):
+class _TagFilterModel(BaseModel):
+    """Tag Filter Model with a match mode parameter."""
+
+    tags: list[str]
+    tags_match_mode: str | None
+
+
+class _TagsFilter(BaseParam[_TagFilterModel]):
     """Filter on tags."""
 
     def to_orm(self, select: Select) -> Select:
         if self.skip_none is False:
             raise ValueError(f"Cannot set 'skip_none' to False on a 
{type(self)}")
 
-        if not self.value:
+        if not self.value or not self.value.tags:
             return select
 
-        conditions = [DagModel.tags.any(DagTag.name == tag) for tag in 
self.value]
-        return select.where(or_(*conditions))
+        if not self.value.tags_match_mode or self.value.tags_match_mode == 
"any":
+            conditions = [DagModel.tags.any(DagTag.name == tag) for tag in 
self.value.tags]
+            return select.where(or_(*conditions))

Review Comment:
   This line is duplicated and can be taken out of the `if, else`.
   ```
   conditions = ...
   operator = or_
   
   
   return select.where(operator(*conditions))
   ```



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