on master help sign in
add ByteString support to persistent driver
commit61fd8394c13c7db68f60e1c71d9cf85a786b4c26 authorAgentM <agentm@themactionfaction.com> dateFri 16 Oct 2015, 12:59 (11 years ago) parentcb07a7d
1 file changed+11−8
Database/Persist/ProjectM36.hs+11−8
Database/Persist/ProjectM36.hs+11−8
@@ -32,6 +32,7 @@ import qualified Data.Conduit.List as CL
3232import ProjectM36.RelationalExpression (unsafeCast)
3333import Data.Typeable (typeRep, typeOf, Proxy(..))
3434import Data.Time.Calendar (Day)
35+import Data.ByteString (ByteString)
3536
3637type ProjectM36Backend = C.Connection
3738
@@ -76,15 +77,17 @@ persistValueAtom val = case val of
7677
7778atomAsPersistValue :: Atom -> PersistValue
7879atomAsPersistValue atom@(Atom atomv) = if typeRep (Proxy :: Proxy Int) == typeOf atomv then
79− PersistInt64 (fromIntegral ((unsafeCast atom) :: Int))
80+ PersistInt64 (fromIntegral ((unsafeCast atom) :: Int))
8081 else if typeRep (Proxy :: Proxy T.Text) == typeOf atomv then
81− PersistText (unsafeCast atom)
82− else if typeRep (Proxy :: Proxy Bool) == typeOf atomv then
83− PersistBool (unsafeCast atom)
84− else if typeRep (Proxy :: Proxy Day) == typeOf atomv then
85− PersistDay (unsafeCast atom)
86− else
87− error "missing conversion"
82+ PersistText (unsafeCast atom)
83+ else if typeRep (Proxy :: Proxy Bool) == typeOf atomv then
84+ PersistBool (unsafeCast atom)
85+ else if typeRep (Proxy :: Proxy Day) == typeOf atomv then
86+ PersistDay (unsafeCast atom)
87+ else if typeRep (Proxy :: Proxy ByteString) == typeOf atomv then
88+ PersistByteString (unsafeCast atom)
89+ else
90+ error "missing conversion"
8891
8992recordAsAtoms :: forall record. (PersistEntity record, PersistEntityBackend record ~ C.Connection)
9093 => Maybe U.UUID -> Attributes -> record -> Either RelationalError (V.Vector Atom)