generated from tpl/purs
chore: prepare v2.0.14
This commit is contained in:
parent
3c686415b0
commit
2e7015b19d
90
README.md
90
README.md
@ -259,59 +259,59 @@ the api of [`node-postgres`]:
|
|||||||
- release clients with [`Pool.release`] or [`Pool.destroy`]
|
- release clients with [`Pool.release`] or [`Pool.destroy`]
|
||||||
- release with [`Pool.end`]
|
- release with [`Pool.end`]
|
||||||
|
|
||||||
[`Pool`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Effect.Aff.Postgres.Pool#t:Pool
|
[`Pool`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Effect.Aff.Postgres.Pool#t:Pool
|
||||||
[`Config`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Effect.Aff.Postgres.Pool#t:Config
|
[`Config`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Effect.Aff.Postgres.Pool#t:Config
|
||||||
[`Pool.make`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Effect.Aff.Postgres.Pool#v:make
|
[`Pool.make`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Effect.Aff.Postgres.Pool#v:make
|
||||||
[`Pool.end`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Effect.Aff.Postgres.Pool#v:end
|
[`Pool.end`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Effect.Aff.Postgres.Pool#v:end
|
||||||
[`Pool.connect`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Effect.Aff.Postgres.Pool#v:connect
|
[`Pool.connect`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Effect.Aff.Postgres.Pool#v:connect
|
||||||
[`Pool.destroy`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Effect.Aff.Postgres.Pool#v:destroy
|
[`Pool.destroy`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Effect.Aff.Postgres.Pool#v:destroy
|
||||||
[`Pool.release`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Effect.Aff.Postgres.Pool#v:release
|
[`Pool.release`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Effect.Aff.Postgres.Pool#v:release
|
||||||
|
|
||||||
[`Client`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Effect.Aff.Postgres.Client#t:Client
|
[`Client`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Effect.Aff.Postgres.Client#t:Client
|
||||||
[`Client.end`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Effect.Aff.Postgres.Client#v:end
|
[`Client.end`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Effect.Aff.Postgres.Client#v:end
|
||||||
[`Client.make`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Effect.Aff.Postgres.Client#v:make
|
[`Client.make`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Effect.Aff.Postgres.Client#v:make
|
||||||
[`Client.connected`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Effect.Aff.Postgres.Client#v:connected
|
[`Client.connected`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Effect.Aff.Postgres.Client#v:connected
|
||||||
[`Client.query`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Effect.Aff.Postgres.Client#v:query
|
[`Client.query`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Effect.Aff.Postgres.Client#v:query
|
||||||
[`Client.queryRaw`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Effect.Aff.Postgres.Client#v:queryRaw
|
[`Client.queryRaw`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Effect.Aff.Postgres.Client#v:queryRaw
|
||||||
[`Client.exec`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Effect.Aff.Postgres.Client#v:exec
|
[`Client.exec`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Effect.Aff.Postgres.Client#v:exec
|
||||||
|
|
||||||
[`Range`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Range#t:Range
|
[`Range`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Data.Postgres.Range#t:Range
|
||||||
[`Range.gt`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Range#v:gt
|
[`Range.gt`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Data.Postgres.Range#v:gt
|
||||||
[`Range.gte`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Range#v:gte
|
[`Range.gte`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Data.Postgres.Range#v:gte
|
||||||
[`Range.lt`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Range#v:lt
|
[`Range.lt`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Data.Postgres.Range#v:lt
|
||||||
[`Range.lte`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Range#v:lte
|
[`Range.lte`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Data.Postgres.Range#v:lte
|
||||||
|
|
||||||
[`Raw`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Raw#t:Raw
|
[`Raw`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Data.Postgres.Raw#t:Raw
|
||||||
[`Null`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Raw#t:Null
|
[`Null`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Data.Postgres.Raw#t:Null
|
||||||
|
|
||||||
[`Serialize`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres#t:Serialize
|
[`Serialize`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Data.Postgres#t:Serialize
|
||||||
[`Deserialize`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres#t:Deserialize
|
[`Deserialize`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Data.Postgres#t:Deserialize
|
||||||
[`Rep`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres#t:Rep
|
[`Rep`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Data.Postgres#t:Rep
|
||||||
[`modifyPgTypes`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres#v:modifyPgTypes
|
[`modifyPgTypes`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Data.Postgres#v:modifyPgTypes
|
||||||
|
|
||||||
[`Result`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Result#t:Result
|
[`Result`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Data.Postgres.Result#t:Result
|
||||||
[`FromRow`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Result#t:FromRow
|
[`FromRow`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Data.Postgres.Result#t:FromRow
|
||||||
[`FromRows`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Result#t:FromRows
|
[`FromRows`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Data.Postgres.Result#t:FromRows
|
||||||
|
|
||||||
[`Query`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Query#t:Query
|
[`Query`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Data.Postgres.Query#t:Query
|
||||||
[`AsQuery`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Query#t:AsQuery
|
[`AsQuery`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Data.Postgres.Query#t:AsQuery
|
||||||
|
|
||||||
[`Query.Builder`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Query.Builder#t:Builder
|
[`Query.Builder`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Data.Postgres.Query.Builder#t:Builder
|
||||||
[`Query.Builder.param`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Query.Builder#v:param
|
[`Query.Builder.param`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Data.Postgres.Query.Builder#v:param
|
||||||
[`Query.Builder.build`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Query.Builder#v:build
|
[`Query.Builder.build`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Data.Postgres.Query.Builder#v:build
|
||||||
|
|
||||||
[`MonadCursor`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Control.Monad.Postgres#t:MonadCursor
|
[`MonadCursor`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Control.Monad.Postgres#t:MonadCursor
|
||||||
[`MonadSession`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Control.Monad.Postgres#t:MonadSession
|
[`MonadSession`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Control.Monad.Postgres#t:MonadSession
|
||||||
[`CursorT`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Control.Monad.Postgres#t:CursorT
|
[`CursorT`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Control.Monad.Postgres#t:CursorT
|
||||||
[`SessionT`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Control.Monad.Postgres#t:SessionT
|
[`SessionT`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Control.Monad.Postgres#t:SessionT
|
||||||
[`PostgresT`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Control.Monad.Postgres#t:PostgresT
|
[`PostgresT`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Control.Monad.Postgres#t:PostgresT
|
||||||
[`cursor`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Control.Monad.Postgres#v:cursor
|
[`cursor`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Control.Monad.Postgres#v:cursor
|
||||||
[`session`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Control.Monad.Postgres#v:session
|
[`session`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Control.Monad.Postgres#v:session
|
||||||
[`transaction`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Control.Monad.Postgres#v:transaction
|
[`transaction`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Control.Monad.Postgres#v:transaction
|
||||||
[`runPostgres`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Control.Monad.Postgres#v:runPostgres
|
[`runPostgres`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Control.Monad.Postgres#v:runPostgres
|
||||||
[`query`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Control.Monad.Postgres#v:query
|
[`query`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Control.Monad.Postgres#v:query
|
||||||
[`exec`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Control.Monad.Postgres#v:exec
|
[`exec`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Control.Monad.Postgres#v:exec
|
||||||
[`exec_`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Control.Monad.Postgres#v:exec_
|
[`exec_`]: https://pursuit.purescript.org/////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.14/Control.Monad.Postgres#v:exec_
|
||||||
|
|
||||||
[`node-postgres`]: https://node-postgres.com/
|
[`node-postgres`]: https://node-postgres.com/
|
||||||
[`pg-types`]: https://github.com/brianc/node-pg-types/
|
[`pg-types`]: https://github.com/brianc/node-pg-types/
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package:
|
package:
|
||||||
name: postgresql
|
name: postgresql
|
||||||
publish:
|
publish:
|
||||||
version: '2.0.13'
|
version: '2.0.14'
|
||||||
license: 'GPL-3.0-or-later'
|
license: 'GPL-3.0-or-later'
|
||||||
location:
|
location:
|
||||||
githubOwner: 'cakekindel'
|
githubOwner: 'cakekindel'
|
||||||
|
@ -3,63 +3,39 @@ module Pipes.Postgres where
|
|||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
import Control.Monad.Cont (lift)
|
import Control.Monad.Cont (lift)
|
||||||
import Control.Monad.Error.Class (class MonadError, class MonadThrow, catchError, throwError)
|
import Control.Monad.Error.Class (class MonadError, class MonadThrow)
|
||||||
import Control.Monad.Morph (hoist)
|
import Control.Monad.Morph (hoist)
|
||||||
import Control.Monad.Postgres (PostgresT)
|
import Control.Monad.Postgres (SessionT)
|
||||||
import Control.Monad.Reader (ask)
|
import Control.Monad.Reader (ask)
|
||||||
import Data.Maybe (Maybe(..))
|
import Data.Maybe (Maybe)
|
||||||
import Effect.Aff.Class (class MonadAff, liftAff)
|
import Effect.Aff.Class (class MonadAff)
|
||||||
import Effect.Aff.Postgres.Client as Client
|
import Effect.Aff.Postgres.Client as Client
|
||||||
import Effect.Aff.Postgres.Pool as Pool
|
|
||||||
import Effect.Class (liftEffect)
|
import Effect.Class (liftEffect)
|
||||||
import Effect.Exception (Error)
|
import Effect.Exception (Error)
|
||||||
import Effect.Postgres.Error.RE as RE
|
import Effect.Postgres.Error.RE as RE
|
||||||
import Node.Buffer (Buffer)
|
import Node.Buffer (Buffer)
|
||||||
import Node.Stream.Object as O
|
import Node.Stream.Object as O
|
||||||
import Pipes ((>->))
|
|
||||||
import Pipes.Core (Consumer, Producer)
|
import Pipes.Core (Consumer, Producer)
|
||||||
import Pipes.Node.Stream (fromReadable, fromWritable)
|
import Pipes.Node.Stream (fromReadable, fromWritable)
|
||||||
import Pipes.Prelude as Pipes
|
|
||||||
|
|
||||||
stdin
|
stdin
|
||||||
:: forall m
|
:: forall m
|
||||||
. MonadAff m
|
. MonadAff m
|
||||||
=> MonadError Error m
|
=> MonadError Error m
|
||||||
=> String
|
=> String
|
||||||
-> Consumer (Maybe Buffer) (PostgresT m) Unit
|
-> Consumer (Maybe Buffer) (SessionT m) Unit
|
||||||
stdin q = do
|
stdin q = do
|
||||||
pool <- lift ask
|
client <- lift ask
|
||||||
client <- lift $ RE.liftExcept $ hoist liftAff $ Pool.connect pool
|
|
||||||
stream <- lift $ RE.liftExcept $ hoist liftEffect $ Client.execWithStdin q client
|
stream <- lift $ RE.liftExcept $ hoist liftEffect $ Client.execWithStdin q client
|
||||||
lift $ RE.liftExcept $ hoist liftAff $ void $ Client.exec "begin" client
|
hoist lift (fromWritable $ O.unsafeFromBufferWritable stream)
|
||||||
let
|
|
||||||
releaseOnEOS Nothing = do
|
|
||||||
RE.liftExcept $ hoist liftAff $ void $ Client.exec "commit" client
|
|
||||||
RE.liftExcept $ hoist liftEffect $ Pool.release pool client
|
|
||||||
pure Nothing
|
|
||||||
releaseOnEOS (Just a) = pure (Just a)
|
|
||||||
|
|
||||||
pipe = Pipes.mapM releaseOnEOS >-> hoist lift (fromWritable $ O.unsafeFromBufferWritable stream)
|
|
||||||
err e = lift do
|
|
||||||
RE.liftExcept $ hoist liftAff $ void $ Client.exec "rollback" client
|
|
||||||
RE.liftExcept $ hoist liftEffect $ Pool.release pool client
|
|
||||||
throwError e
|
|
||||||
|
|
||||||
catchError pipe err
|
|
||||||
|
|
||||||
stdout
|
stdout
|
||||||
:: forall m
|
:: forall m
|
||||||
. MonadAff m
|
. MonadAff m
|
||||||
=> MonadThrow Error m
|
=> MonadThrow Error m
|
||||||
=> String
|
=> String
|
||||||
-> Producer (Maybe Buffer) (PostgresT m) Unit
|
-> Producer (Maybe Buffer) (SessionT m) Unit
|
||||||
stdout q = do
|
stdout q = do
|
||||||
pool <- lift ask
|
client <- lift ask
|
||||||
client <- lift $ RE.liftExcept $ hoist liftAff $ Pool.connect pool
|
|
||||||
stream <- lift $ RE.liftExcept $ hoist liftEffect $ Client.queryWithStdout q client
|
stream <- lift $ RE.liftExcept $ hoist liftEffect $ Client.queryWithStdout q client
|
||||||
let
|
|
||||||
releaseOnEOS :: Maybe Buffer -> PostgresT m (Maybe Buffer)
|
|
||||||
releaseOnEOS Nothing = RE.liftExcept $ hoist liftEffect $ Pool.release pool client $> Nothing
|
|
||||||
releaseOnEOS (Just a) = pure (Just a)
|
|
||||||
hoist lift (fromReadable (O.unsafeFromBufferReadable stream))
|
hoist lift (fromReadable (O.unsafeFromBufferReadable stream))
|
||||||
>-> Pipes.mapM releaseOnEOS
|
|
||||||
|
Loading…
Reference in New Issue
Block a user