Skip to content

Commit

Permalink
🐛 DMS Equals filter on property (#1026)
Browse files Browse the repository at this point in the history
# Description

See changelog below.

## Bump

- [x] Patch
- [ ] Minor
- [ ] Skip

## Changelog
### Fixed

- Reading a data model with a view with an equals filter on a property
no longer raises a `AttributeError: 'str' object has no attribute 'get'`
error.
  • Loading branch information
doctrino authored Mar 3, 2025
1 parent 7d80a2b commit 563ac41
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cognite/neat/_rules/models/entities/_wrapped.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ def as_dms_filter(self, default: Any | None = None) -> dm.filters.Filter:
@classmethod
def from_dms_filter(cls, filter: dm.Filter) -> "DMSFilter":
dumped = filter.dump()
if (body := dumped.get(dm.filters.Equals._filter_name)) and (value := body.get("value")):
if (
(body := dumped.get(dm.filters.Equals._filter_name))
and (value := body.get("value"))
and isinstance(value, dict)
):
space = value.get("space")
external_id = value.get("externalId")
if space is not None and external_id is not None:
Expand Down
5 changes: 5 additions & 0 deletions tests/tests_unit/rules/test_models/test_wrapped_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ def test_load(self, cls_: type[WrappedEntity], raw: Any, expected: WrappedEntity
]
),
),
pytest.param(
dm.filters.Equals(["govern-space", "Property", "type"], "Input"),
RawFilter(filter='{"equals": {"property": ["govern-space", "Property", "type"], "value": "Input"}}'),
id="Equal filter on property",
),
],
)
def test_from_dms_filter(self, filter_: dm.Filter, expected: DMSFilter) -> None:
Expand Down

0 comments on commit 563ac41

Please sign in to comment.