Skip to content

Commit

Permalink
fix: row dictizer ignores invisible columns
Browse files Browse the repository at this point in the history
  • Loading branch information
smotornyuk committed Dec 3, 2024
1 parent 31a44ca commit 0ec3eab
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions ckanext/collection/utils/serialize/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ class Serializer(
"""

value_serializers: dict[
str, types.ValueSerializer
] = internal.configurable_attribute(
default_factory=lambda self: {},
value_serializers: dict[str, types.ValueSerializer] = (
internal.configurable_attribute(
default_factory=lambda self: {},
)
)
row_dictizer: Callable[[Any], dict[str, Any]] = internal.configurable_attribute(
basic_row_dictizer,
Expand All @@ -108,16 +108,11 @@ def serialize_value(self, value: Any, name: str, record: Any):
def dictize_row(self, row: Any) -> dict[str, Any]:
"""Transform single data record into serializable dictionary."""
result = self.row_dictizer(row)
if fields := self.attached.columns.names:
visible = self.attached.columns.visible
else:
fields = list(result)
visible = set(fields)
fields = self.attached.columns.names or list(result)

return {
field: self.serialize_value(result.get(field), field, row)
for field in fields
if field in visible
}


Expand Down

0 comments on commit 0ec3eab

Please sign in to comment.