From 0ec3eaba1410ef59e9881fadd24297d5c84475ea Mon Sep 17 00:00:00 2001 From: Sergey Motornyuk Date: Tue, 3 Dec 2024 16:32:50 +0200 Subject: [PATCH] fix: row dictizer ignores invisible columns --- ckanext/collection/utils/serialize/__init__.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/ckanext/collection/utils/serialize/__init__.py b/ckanext/collection/utils/serialize/__init__.py index 2faaaab..af6bb49 100644 --- a/ckanext/collection/utils/serialize/__init__.py +++ b/ckanext/collection/utils/serialize/__init__.py @@ -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, @@ -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 }