From 6c7bd8af2a9fb574110b5ed2ea0367581db07976 Mon Sep 17 00:00:00 2001 From: Gautier DI FOLCO Date: Mon, 1 Jan 2024 13:58:11 +0100 Subject: [PATCH] fix: reindex ToJSON broken (not omitting nulls) after deriving-aeson drop --- .../Internal/Versions/Common/Types/Reindex.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Database/Bloodhound/Internal/Versions/Common/Types/Reindex.hs b/src/Database/Bloodhound/Internal/Versions/Common/Types/Reindex.hs index cc4b953..700f6b6 100644 --- a/src/Database/Bloodhound/Internal/Versions/Common/Types/Reindex.hs +++ b/src/Database/Bloodhound/Internal/Versions/Common/Types/Reindex.hs @@ -10,6 +10,7 @@ module Database.Bloodhound.Internal.Versions.Common.Types.Reindex where import Data.Aeson import Data.List.NonEmpty import Data.Text (Text) +import Database.Bloodhound.Internal.Utils.Imports (omitNulls) import Database.Bloodhound.Internal.Versions.Common.Types.Newtypes (IndexName) import Database.Bloodhound.Internal.Versions.Common.Types.Query (Query) import Database.Bloodhound.Internal.Versions.Common.Types.Script (ScriptLanguage) @@ -25,7 +26,7 @@ data ReindexRequest = ReindexRequest instance ToJSON ReindexRequest where toJSON ReindexRequest {..} = - object + omitNulls [ "conflicts" .= reindexConflicts, "source" .= reindexSource, "dest" .= reindexDest, @@ -69,7 +70,7 @@ data ReindexSource = ReindexSource instance ToJSON ReindexSource where toJSON ReindexSource {..} = - object + omitNulls [ "index" .= reindexSourceIndex, "max_docs" .= reindexSourceMaxDocs, "query" .= reindexSourceQuery, @@ -94,7 +95,7 @@ data ReindexSlice = ReindexSlice instance ToJSON ReindexSlice where toJSON ReindexSlice {..} = - object ["id" .= reindexSliceId, "max" .= reindexSliceMax] + omitNulls ["id" .= reindexSliceId, "max" .= reindexSliceMax] instance FromJSON ReindexSlice where parseJSON = withObject "ReindexSlice" $ \v -> @@ -109,7 +110,7 @@ data ReindexDest = ReindexDest instance ToJSON ReindexDest where toJSON ReindexDest {..} = - object + omitNulls [ "index" .= reindexDestIndex, "version_type" .= reindexDestVersionType, "op_type" .= reindexDestOpType @@ -212,7 +213,7 @@ data ReindexResponse = ReindexResponse instance ToJSON ReindexResponse where toJSON ReindexResponse {..} = - object + omitNulls [ "took" .= reindexResponseTook, "updated" .= reindexResponseUpdated, "created" .= reindexResponseCreated,