@@ -29,6 +29,7 @@ import Control.Monad.Trans.Either
29import Database.Persist.Class
29import Database.Persist.Class
30import qualified Database.Persist.Types as DPT
30import qualified Database.Persist.Types as DPT
31import qualified Data.Set as S
31import qualified Data.Set as S
32+import qualified Data.Conduit.List as CL
33type ProjectM36Backend = C.Connection
34type ProjectM36Backend = C.Connection
@@ -498,5 +499,22 @@ instance PersistQuery C.Connection where
498 Left err -> Trans.liftIO $ throwIO $ PersistError "count pooped"
499 Left err -> Trans.liftIO $ throwIO $ PersistError "count pooped"
499 Right c -> return c
500 Right c -> return c
502+ --no select options currently supported (sorting, limiting)
503+ selectSourceRes _ (_:_) = Trans.liftIO $ throwIO $ PersistError "select options not yet supported"
501− selectSourceRes = undefined
504+ selectSourceRes filters [] = do
506+ entities <- runEitherT $ do
507+ restrictionPredicate <- hoistEither $ multiFilterAsRestrictionPredicate True filters
508+ let entDef = entityDef $ dummyFromFilters filters
509+ relVarName = unDBName $ entityDB entDef
510+ restrictionExpr = Restrict restrictionPredicate (RelationVariable relVarName)
511+ tupleMapper tuple = Trans.liftIO $ fromPersistValuesThrow entDef tuple
512+ rel <- Trans.liftIO $ C.executeRelationalExpr conn restrictionExpr
514+ Left err -> Trans.liftIO $ throwIO $ PersistError (T.pack (show err))
515+ Right (Relation _ tupleSet) -> mapM tupleMapper $ HS.toList tupleSet --refactor to use some relation accessors- here we convert a relation to a matrix, effectively (especially to support future sorting)
517+ Left err -> Trans.liftIO $ throwIO $ PersistError (T.pack $ show err)
518+ Right entities' -> return $ return $ CL.sourceList entities'
502 selectKeysRes = undefined
520 selectKeysRes = undefined