@@ -146,15 +146,15 @@ def __get_tag_ids(self, tag_name: str, include_children: bool = True) -> list[in
146146 def __separate_tags (
147147 self , terms : list [AST ], only_single : bool = True
148148 ) -> tuple [list [int ], list [ColumnElement [bool ]]]:
149- tag_ids : list [int ] = []
149+ tag_ids : set [int ] = set ()
150150 bool_expressions : list [ColumnElement [bool ]] = []
151151
152152 for term in terms :
153153 if isinstance (term , Constraint ) and len (term .properties ) == 0 :
154154 match term .type :
155155 case ConstraintType .TagID :
156156 try :
157- tag_ids .append (int (term .value ))
157+ tag_ids .add (int (term .value ))
158158 except ValueError :
159159 logger .error (
160160 "[SQLBoolExpressionBuilder] Could not cast value to an int Tag ID" ,
@@ -164,10 +164,10 @@ def __separate_tags(
164164 case ConstraintType .Tag :
165165 ids = self .__get_tag_ids (term .value )
166166 if not only_single :
167- tag_ids .extend (ids )
167+ tag_ids .update (ids )
168168 continue
169169 elif len (ids ) == 1 :
170- tag_ids .append (ids [0 ])
170+ tag_ids .add (ids [0 ])
171171 continue
172172 case ConstraintType .FileType :
173173 pass
@@ -179,7 +179,7 @@ def __separate_tags(
179179 raise NotImplementedError (f"Unhandled constraint: '{ term .type } '" )
180180
181181 bool_expressions .append (self .visit (term ))
182- return tag_ids , bool_expressions
182+ return list ( tag_ids ) , bool_expressions
183183
184184 def __entry_has_all_tags (self , tag_ids : list [int ]) -> ColumnElement [bool ]:
185185 """Returns Binary Expression that is true if the Entry has all provided tag ids."""
0 commit comments