Merge branch 'sledorze-master'

This commit is contained in:
rightfold 2017-06-13 11:49:28 +02:00
commit 97583e0cc8
No known key found for this signature in database
GPG Key ID: 199D0373AC917A8F
2 changed files with 9 additions and 1 deletions

View File

@ -2,7 +2,8 @@
purescript-postgresql-client is a PostgreSQL client library for PureScript. purescript-postgresql-client is a PostgreSQL client library for PureScript.
To use this library, you need to add `pg` as an npm dependency. To use this library, you need to add `pg` as an npm dependency. You can also
find this npm library on [https://github.com/brianc/node-postgres][pg].
The purspgpp preprocessor has been replaced by [sqltopurs], which is a code The purspgpp preprocessor has been replaced by [sqltopurs], which is a code
generator instead of a preprocessor, and easier to use. generator instead of a preprocessor, and easier to use.

View File

@ -3,6 +3,7 @@ module Database.PostgreSQL.Value where
import Control.Monad.Eff (kind Effect) import Control.Monad.Eff (kind Effect)
import Control.Monad.Error.Class (throwError) import Control.Monad.Error.Class (throwError)
import Control.Monad.Except (runExcept) import Control.Monad.Except (runExcept)
import Data.Array as Array
import Data.Bifunctor (lmap) import Data.Bifunctor (lmap)
import Data.ByteString (ByteString) import Data.ByteString (ByteString)
import Data.DateTime.Instant (Instant) import Data.DateTime.Instant (Instant)
@ -52,9 +53,15 @@ instance toSQLValueString :: ToSQLValue String where
instance fromSQLValueString :: FromSQLValue String where instance fromSQLValueString :: FromSQLValue String where
fromSQLValue = lmap show <<< runExcept <<< readString fromSQLValue = lmap show <<< runExcept <<< readString
instance toSQLValueArray :: (ToSQLValue a) => ToSQLValue (Array a) where
toSQLValue = toForeign <<< map toSQLValue
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 toSQLValueList :: (ToSQLValue a) => ToSQLValue (List a) where
toSQLValue = toForeign <<< Array.fromFoldable <<< 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