diff --git a/bower.json b/bower.json index b476531..2e2a510 100644 --- a/bower.json +++ b/bower.json @@ -6,7 +6,6 @@ "purescript-transformers": "^2.0.2", "purescript-lists": "^3.2.1", "purescript-foreign": "^3.0.1", - "purescript-partial": "^1.1.2", "purescript-tuples": "^3.0.0", "purescript-aff": "^2.0.2", "purescript-either": "^2.0.0", diff --git a/src/Database/PostgreSQL.purs b/src/Database/PostgreSQL.purs index 0a080ed..0bd7bb2 100644 --- a/src/Database/PostgreSQL.purs +++ b/src/Database/PostgreSQL.purs @@ -21,6 +21,7 @@ module Database.PostgreSQL ) where import Control.Monad.Aff (Aff) +import Control.Monad.Eff.Exception (error) import Control.Monad.Error.Class (catchError, throwError) import Control.Monad.Except (runExcept) import Data.Array (head) @@ -31,12 +32,11 @@ import Data.Foreign (Foreign, isNull, readArray, readChar, readInt, readString, import Data.Foreign.Null (writeNull) import Data.List (List) import Data.List as List -import Data.Maybe (fromJust, Maybe(..)) +import Data.Maybe (Maybe(..)) import Data.Newtype (class Newtype) import Data.Traversable (traverse) import Data.Tuple (fst, Tuple) import Data.Tuple.Nested ((/\), tuple1, tuple2, tuple3, tuple4, tuple5) -import Partial.Unsafe (unsafePartial) import Prelude foreign import data POSTGRESQL :: ! @@ -208,7 +208,9 @@ query -> Aff (postgreSQL :: POSTGRESQL | eff) (Array o) query conn (Query sql) values = _query conn sql (toSQLRow values) - <#> map (unsafePartial fromJust <<< fromSQLRow) + >>= traverse (fromSQLRow >>> case _ of + Just row -> pure row + Nothing -> throwError (error "incompatible row structure")) scalar :: ∀ i o eff