SQL: Use ANY() with arrays, not IN

This commit is contained in:
fr33domlover 2016-07-28 16:50:08 +00:00
parent 5c153b0294
commit 1c2e5f86af
4 changed files with 8 additions and 8 deletions

View file

@ -132,7 +132,7 @@ xcyclicn' follow filter minitials proxy = do
Just initials -> mconcat Just initials -> mconcat
[ " FROM ", dbname $ entityDB tNode [ " FROM ", dbname $ entityDB tNode
, " WHERE ", entityDB tNode ^* fieldDB (entityId tNode) , " WHERE ", entityDB tNode ^* fieldDB (entityId tNode)
, " IN ?" , " = ANY(?)"
] ]
] ]

View file

@ -157,7 +157,7 @@ xmpathm' follow filter msource mdest mlen mlim proxy = do
Just _ -> mconcat Just _ -> mconcat
[ " FROM ", dbname $ entityDB tNode [ " FROM ", dbname $ entityDB tNode
, " WHERE ", entityDB tNode ^* fieldDB (entityId tNode) , " WHERE ", entityDB tNode ^* fieldDB (entityId tNode)
, " IN ?" , " = ANY(?)"
] ]
, " UNION ALL " , " UNION ALL "
, case follow of , case follow of
@ -174,10 +174,10 @@ xmpathm' follow filter msource mdest mlen mlim proxy = do
, " FROM ", dbname temp , " FROM ", dbname temp
, case mdest of , case mdest of
Nothing -> "" Nothing -> ""
Just _ -> " WHERE ", temp ^* tid, " IN ?" Just _ -> " WHERE " <> temp ^* tid <> " = ANY(?)"
, case mlen of , case mlen of
Nothing -> "" Nothing -> ""
Just _ -> " AND array_length(", temp ^* tpath, ", 1) <= ?" Just _ -> " AND array_length(" <> temp ^* tpath <> ", 1) <= ?"
, " ORDER BY array_length(", temp ^* tpath, ", 1)" , " ORDER BY array_length(", temp ^* tpath, ", 1)"
, case mlim of , case mlim of
Nothing -> "" Nothing -> ""

View file

@ -127,7 +127,7 @@ xreachable' follow filter initials mlen proxy = do
, "FALSE" , "FALSE"
, " FROM ", dbname $ entityDB tNode , " FROM ", dbname $ entityDB tNode
, " WHERE ", entityDB tNode ^* fieldDB (entityId tNode) , " WHERE ", entityDB tNode ^* fieldDB (entityId tNode)
, " IN ?" , " = ANY(?)"
, " UNION ALL " , " UNION ALL "
, case follow of , case follow of
FollowForward -> sqlStep fwd bwd FollowForward -> sqlStep fwd bwd
@ -144,7 +144,7 @@ xreachable' follow filter initials mlen proxy = do
, " WHERE NOT ", temp ^* tcycle , " WHERE NOT ", temp ^* tcycle
, case mlen of , case mlen of
Nothing -> "" Nothing -> ""
Just _ -> " AND array_length(", temp ^* tpath, ", 1) <= ?" Just _ -> " AND array_length(" <> temp ^* tpath <> ", 1) <= ?"
] ]
toP = fmap toPersistValue toP = fmap toPersistValue
toPL = PersistList . map toPersistValue toPL = PersistList . map toPersistValue

View file

@ -114,7 +114,7 @@ trrSelect proxy = do
, "FALSE" , "FALSE"
, " FROM ", dbname $ entityDB tNode , " FROM ", dbname $ entityDB tNode
, " WHERE ", entityDB tNode ^* fieldDB (entityId tNode) , " WHERE ", entityDB tNode ^* fieldDB (entityId tNode)
, " IN ?" , " = ANY(?)"
, " UNION ALL " , " UNION ALL "
, sqlStep fwd bwd , sqlStep fwd bwd
, " )" , " )"
@ -198,7 +198,7 @@ trrApply proxy = do
, "FALSE" , "FALSE"
, " FROM ", dbname $ entityDB tNode , " FROM ", dbname $ entityDB tNode
, " WHERE ", entityDB tNode ^* fieldDB (entityId tNode) , " WHERE ", entityDB tNode ^* fieldDB (entityId tNode)
, " IN ?" , " = ANY(?)"
, " UNION ALL " , " UNION ALL "
, sqlStep fwd bwd , sqlStep fwd bwd
, " ) DELETE FROM ", dbname $ entityDB tEdge , " ) DELETE FROM ", dbname $ entityDB tEdge