Commit 328cb395 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] upgrading without checking Hyperdatas

parent 0a3a029f
......@@ -33,10 +33,9 @@ main = do
let
updateNodes :: Cmd GargError [Int64]
updateNodes = updateNodesWithType
updateNodes = updateNodesWithType_
NodeList
(Proxy :: Proxy HyperdataList)
(\_ -> defaultHyperdataList)
defaultHyperdataList
withDevEnv iniPath $ \env -> do
x <- runCmdDev env updateNodes
......
......@@ -160,13 +160,24 @@ selectNodesWithParentID n = proc () -> do
-- runCmdReplEasy (getNodesWithType NodeList (Proxy :: Proxy HyperdataList))
getNodesWithType :: (HasNodeError err, JSONB a) => NodeType -> proxy a -> Cmd err [Node a]
getNodesWithType nt _ = runOpaQuery $ selectNodesWithType nt
selectNodesWithType :: NodeType -> Query NodeRead
selectNodesWithType nt = proc () -> do
where
selectNodesWithType :: NodeType -> Query NodeRead
selectNodesWithType nt = proc () -> do
row@(Node _ _ tn _ _ _ _ _) <- queryNodeTable -< ()
restrict -< tn .== (pgInt4 $ nodeTypeId nt)
returnA -< row
getNodesIdWithType :: HasNodeError err => NodeType -> Cmd err [NodeId]
getNodesIdWithType nt = do
ns <- runOpaQuery $ selectNodesIdWithType nt
pure (map NodeId ns)
selectNodesIdWithType :: NodeType -> Query (Column PGInt4)
selectNodesIdWithType nt = proc () -> do
row@(Node _ _ tn _ _ _ _ _) <- queryNodeTable -< ()
restrict -< tn .== (pgInt4 $ nodeTypeId nt)
returnA -< _node_id row
------------------------------------------------------------------------
......
......@@ -48,3 +48,15 @@ updateNodesWithType nt p f = do
mapM (\n -> updateHyperdata (_node_id n) (f $ _node_hyperdata n)) ns
-- | In case the Hyperdata Types are not compatible
updateNodesWithType_ :: ( HasNodeError err
, JSONB a
, ToJSON a
) => NodeType -> a -> Cmd err [Int64]
updateNodesWithType_ nt h = do
ns <- getNodesIdWithType nt
mapM (\n -> updateHyperdata n h) ns
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment