diff --git a/src/zenml/models/v2/base/scoped.py b/src/zenml/models/v2/base/scoped.py index 830ad18d86..f5267f4840 100644 --- a/src/zenml/models/v2/base/scoped.py +++ b/src/zenml/models/v2/base/scoped.py @@ -542,7 +542,7 @@ def apply_sorting( sort_by, operand = self.sorting_params if sort_by == "tag": - from sqlmodel import asc, desc, func + from sqlmodel import and_, asc, desc, func from zenml.enums import SorterOps, TaggableResourceTypes from zenml.zen_stores.schemas import ( @@ -570,10 +570,10 @@ def apply_sorting( query = ( query.outerjoin( TagResourceSchema, - (table.id == TagResourceSchema.resource_id) - & ( + and_( + table.id == TagResourceSchema.resource_id, TagResourceSchema.resource_type - == resource_type_mapping[table] + == resource_type_mapping[table], ), ) .outerjoin(TagSchema, TagResourceSchema.tag_id == TagSchema.id)