summaryrefslogtreecommitdiff
path: root/Omni
diff options
context:
space:
mode:
authorBen Sima <ben@bensima.com>2025-11-29 18:03:58 -0500
committerBen Sima <ben@bensima.com>2025-11-29 18:03:58 -0500
commit4ef0658b1eb2943ac14dfa3c447f538289e6f50d (patch)
tree16635b2665dcf83b0be19cd4aa4d2749b710e0ed /Omni
parentb60c04b0cd3f0d865ca04b258903694680ebafef (diff)
Fix nullable SQL field
Diffstat (limited to 'Omni')
-rw-r--r--Omni/Task/Core.hs20
1 files changed, 12 insertions, 8 deletions
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))