From 4ef0658b1eb2943ac14dfa3c447f538289e6f50d Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sat, 29 Nov 2025 18:03:58 -0500 Subject: Fix nullable SQL field --- Omni/Task/Core.hs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'Omni/Task') diff --git a/Omni/Task/Core.hs b/Omni/Task/Core.hs index 1be97b9..773a01f 100644 --- a/Omni/Task/Core.hs +++ b/Omni/Task/Core.hs @@ -244,10 +244,12 @@ instance SQL.ToField ActivityStage where -- Store dependencies as JSON text instance SQL.FromField [Dependency] where fromField f = do - t <- SQL.fromField f :: SQLOk.Ok String - case Aeson.decode (BLC.pack t) of - Just x -> pure x - Nothing -> pure [] -- Default to empty if parse fail or null + mt <- SQL.fromField f :: SQLOk.Ok (Maybe String) + case mt of + Nothing -> pure [] + Just t -> case Aeson.decode (BLC.pack t) of + Just x -> pure x + Nothing -> pure [] instance SQL.ToField [Dependency] where toField deps = SQL.toField (BLC.unpack (encode deps)) @@ -255,10 +257,12 @@ instance SQL.ToField [Dependency] where -- Store comments as JSON text instance SQL.FromField [Comment] where fromField f = do - t <- SQL.fromField f :: SQLOk.Ok String - case Aeson.decode (BLC.pack t) of - Just x -> pure x - Nothing -> pure [] -- Default to empty if parse fail or null + mt <- SQL.fromField f :: SQLOk.Ok (Maybe String) + case mt of + Nothing -> pure [] + Just t -> case Aeson.decode (BLC.pack t) of + Just x -> pure x + Nothing -> pure [] instance SQL.ToField [Comment] where toField comments = SQL.toField (BLC.unpack (encode comments)) -- cgit v1.2.3