From 411eed9ad37e74619e8f415161ccc02091ed015e Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Tue, 9 Jan 2024 16:09:32 +0100 Subject: [PATCH] [backport] fix streaming response --- tipg/factory.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/tipg/factory.py b/tipg/factory.py index 9cefbfa0..5d9e8070 100644 --- a/tipg/factory.py +++ b/tipg/factory.py @@ -753,19 +753,27 @@ async def items( # noqa: C901 MediaType.json, MediaType.ndjson, ): - rows = ( - { - k: v - for k, v in { + if any( + [f.get("geometry", None) is not None for f in item_list["items"]] + ): + rows = ( + { "collectionId": collection.id, "itemId": f.get("id"), **f.get("properties", {}), "geometry": f.get("geometry", None), - }.items() - if v is not None - } - for f in item_list["items"] - ) + } + for f in item_list["items"] + ) + else: + rows = ( + { + "collectionId": collection.id, + "itemId": f.get("id"), + **f.get("properties", {}), + } + for f in item_list["items"] + ) # CSV Response if output_type == MediaType.csv: