diff options
| author | Ben Sima <ben@bensima.com> | 2025-11-29 18:03:58 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bensima.com> | 2025-11-29 18:03:58 -0500 |
| commit | 4ef0658b1eb2943ac14dfa3c447f538289e6f50d (patch) | |
| tree | 16635b2665dcf83b0be19cd4aa4d2749b710e0ed /Omni | |
| parent | b60c04b0cd3f0d865ca04b258903694680ebafef (diff) | |
Fix nullable SQL field
Diffstat (limited to 'Omni')
| -rw-r--r-- | Omni/Task/Core.hs | 20 |
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)) |
