generated from tpl/purs
Update Value.purs
Add support for toSQLValue for list an array
This commit is contained in:
parent
146121c025
commit
49a2465e5f
@ -10,6 +10,7 @@ import Data.Either (Either)
|
|||||||
import Data.Foreign (Foreign, isNull, readArray, readBoolean, readChar, readInt, readNumber, readString, toForeign, unsafeFromForeign)
|
import Data.Foreign (Foreign, isNull, readArray, readBoolean, readChar, readInt, readNumber, readString, toForeign, unsafeFromForeign)
|
||||||
import Data.List (List)
|
import Data.List (List)
|
||||||
import Data.List as List
|
import Data.List as List
|
||||||
|
import Data.Array(fromFoldable)
|
||||||
import Data.Maybe (Maybe(..))
|
import Data.Maybe (Maybe(..))
|
||||||
import Data.Traversable (traverse)
|
import Data.Traversable (traverse)
|
||||||
import Prelude
|
import Prelude
|
||||||
@ -55,9 +56,15 @@ instance fromSQLValueString :: FromSQLValue String where
|
|||||||
instance fromSQLValueArray :: (FromSQLValue a) => FromSQLValue (Array a) where
|
instance fromSQLValueArray :: (FromSQLValue a) => FromSQLValue (Array a) where
|
||||||
fromSQLValue = traverse fromSQLValue <=< lmap show <<< runExcept <<< readArray
|
fromSQLValue = traverse fromSQLValue <=< lmap show <<< runExcept <<< readArray
|
||||||
|
|
||||||
|
instance toSQLValueArray :: (ToSQLValue a) => ToSQLValue (Array a) where
|
||||||
|
toSQLValue = toForeign <<< map toSQLValue
|
||||||
|
|
||||||
instance fromSQLValueList :: (FromSQLValue a) => FromSQLValue (List a) where
|
instance fromSQLValueList :: (FromSQLValue a) => FromSQLValue (List a) where
|
||||||
fromSQLValue = map List.fromFoldable <<< traverse fromSQLValue <=< lmap show <<< runExcept <<< readArray
|
fromSQLValue = map List.fromFoldable <<< traverse fromSQLValue <=< lmap show <<< runExcept <<< readArray
|
||||||
|
|
||||||
|
instance toSQLValueList :: (ToSQLValue a) => ToSQLValue (List a) where
|
||||||
|
toSQLValue = toForeign <<< fromFoldable <<< map toSQLValue
|
||||||
|
|
||||||
instance toSQLValueByteString :: ToSQLValue ByteString where
|
instance toSQLValueByteString :: ToSQLValue ByteString where
|
||||||
toSQLValue = toForeign
|
toSQLValue = toForeign
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user