Skip to content

Commit

Permalink
first attempt to fix issue #372
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhjy committed Feb 28, 2024
1 parent c7e9dca commit c9fc629
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions spinedb_api/filters/tool_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from uuid import uuid4
from sqlalchemy import and_, or_, case, func, Table, Column, ForeignKey
from ..exception import SpineDBAPIError
from sqlalchemy.orm import Session


TOOL_FILTER_TYPE = "tool_filter"
Expand Down Expand Up @@ -228,18 +229,21 @@ def _make_method_filter(tool_feature_method_sq, parameter_value_sq, parameter_de
# Filter passes if either:
# 1) parameter definition is not a feature for the tool
# 2) method is not specified
# 3) value is equal to method
# 4) value is not specified, but default value is equal to method
# 3) value is contained in the listed values of the method
# 4) value is not specified, but default value is contained in the listed values of the method

method_value_id_list = Session().query(tool_feature_method_sq.c.method_list_value_id).subquery()

return case(
[
(
or_(
tool_feature_method_sq.c.parameter_definition_id.is_(None),
tool_feature_method_sq.c.method_list_value_id.is_(None),
parameter_value_sq.c.list_value_id == tool_feature_method_sq.c.method_list_value_id,
parameter_value_sq.c.list_value_id.in_(method_value_id_list),
and_(
parameter_value_sq.c.value.is_(None),
parameter_definition_sq.c.list_value_id == tool_feature_method_sq.c.method_list_value_id,
parameter_definition_sq.c.list_value_id.in_(method_value_id_list),
),
),
True,
Expand Down

0 comments on commit c9fc629

Please sign in to comment.