Skip to content

Commit

Permalink
Revert "fix: row dictizer ignores invisible columns"
Browse files Browse the repository at this point in the history
This reverts commit 0ec3eab.
  • Loading branch information
smotornyuk committed Dec 3, 2024
1 parent 0ec3eab commit e8a14b5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 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,11 +108,16 @@ 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)
fields = self.attached.columns.names or list(result)
if fields := self.attached.columns.names:
visible = self.attached.columns.visible
else:
fields = list(result)
visible = set(fields)

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


Expand Down

0 comments on commit e8a14b5

Please sign in to comment.