chore: prepare v2.0.14

This commit is contained in:
orion 2024-06-25 16:40:19 -05:00
parent 3c686415b0
commit 2e7015b19d
Signed by: orion
GPG Key ID: 6D4165AE4C928719
3 changed files with 55 additions and 79 deletions

View File

@ -259,59 +259,59 @@ the api of [`node-postgres`]:
- release clients with [`Pool.release`] or [`Pool.destroy`]
- release with [`Pool.end`]
[`Pool`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Effect.Aff.Postgres.Pool#t:Pool
[`Config`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/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.end`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/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.destroy`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/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`]: 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.14/Effect.Aff.Postgres.Pool#t:Config
[`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.14/Effect.Aff.Postgres.Pool#v:end
[`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.14/Effect.Aff.Postgres.Pool#v:destroy
[`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.end`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/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.connected`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/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.queryRaw`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/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`]: 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.14/Effect.Aff.Postgres.Client#v:end
[`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.14/Effect.Aff.Postgres.Client#v:connected
[`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.14/Effect.Aff.Postgres.Client#v:queryRaw
[`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.gt`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Range#v:gt
[`Range.gte`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Range#v:gte
[`Range.lt`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Range#v:lt
[`Range.lte`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Range#v:lte
[`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.14/Data.Postgres.Range#v:gt
[`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.14/Data.Postgres.Range#v:lt
[`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
[`Null`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Raw#t:Null
[`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.14/Data.Postgres.Raw#t:Null
[`Serialize`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres#t:Serialize
[`Deserialize`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres#t:Deserialize
[`Rep`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres#t:Rep
[`modifyPgTypes`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres#v:modifyPgTypes
[`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.14/Data.Postgres#t:Deserialize
[`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.14/Data.Postgres#v:modifyPgTypes
[`Result`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Result#t:Result
[`FromRow`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Result#t:FromRow
[`FromRows`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Result#t:FromRows
[`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.14/Data.Postgres.Result#t:FromRow
[`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
[`AsQuery`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Data.Postgres.Query#t:AsQuery
[`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.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.param`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/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`]: 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.14/Data.Postgres.Query.Builder#v:param
[`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
[`MonadSession`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Control.Monad.Postgres#t:MonadSession
[`CursorT`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Control.Monad.Postgres#t:CursorT
[`SessionT`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Control.Monad.Postgres#t:SessionT
[`PostgresT`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Control.Monad.Postgres#t:PostgresT
[`cursor`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Control.Monad.Postgres#v:cursor
[`session`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Control.Monad.Postgres#v:session
[`transaction`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Control.Monad.Postgres#v:transaction
[`runPostgres`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/Control.Monad.Postgres#v:runPostgres
[`query`]: https://pursuit.purescript.org////////////////////////////////////////////////////////packages/purescript-postgresql/2.0.13/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.13/Control.Monad.Postgres#v:exec_
[`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.14/Control.Monad.Postgres#t:MonadSession
[`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.14/Control.Monad.Postgres#t:SessionT
[`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.14/Control.Monad.Postgres#v:cursor
[`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.14/Control.Monad.Postgres#v:transaction
[`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.14/Control.Monad.Postgres#v:query
[`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.14/Control.Monad.Postgres#v:exec_
[`node-postgres`]: https://node-postgres.com/
[`pg-types`]: https://github.com/brianc/node-pg-types/

View File

@ -1,7 +1,7 @@
package:
name: postgresql
publish:
version: '2.0.13'
version: '2.0.14'
license: 'GPL-3.0-or-later'
location:
githubOwner: 'cakekindel'

View File

@ -3,63 +3,39 @@ module Pipes.Postgres where
import Prelude
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.Postgres (PostgresT)
import Control.Monad.Postgres (SessionT)
import Control.Monad.Reader (ask)
import Data.Maybe (Maybe(..))
import Effect.Aff.Class (class MonadAff, liftAff)
import Data.Maybe (Maybe)
import Effect.Aff.Class (class MonadAff)
import Effect.Aff.Postgres.Client as Client
import Effect.Aff.Postgres.Pool as Pool
import Effect.Class (liftEffect)
import Effect.Exception (Error)
import Effect.Postgres.Error.RE as RE
import Node.Buffer (Buffer)
import Node.Stream.Object as O
import Pipes ((>->))
import Pipes.Core (Consumer, Producer)
import Pipes.Node.Stream (fromReadable, fromWritable)
import Pipes.Prelude as Pipes
stdin
:: forall m
. MonadAff m
=> MonadError Error m
=> String
-> Consumer (Maybe Buffer) (PostgresT m) Unit
-> Consumer (Maybe Buffer) (SessionT m) Unit
stdin q = do
pool <- lift ask
client <- lift $ RE.liftExcept $ hoist liftAff $ Pool.connect pool
client <- lift ask
stream <- lift $ RE.liftExcept $ hoist liftEffect $ Client.execWithStdin q client
lift $ RE.liftExcept $ hoist liftAff $ void $ Client.exec "begin" client
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
hoist lift (fromWritable $ O.unsafeFromBufferWritable stream)
stdout
:: forall m
. MonadAff m
=> MonadThrow Error m
=> String
-> Producer (Maybe Buffer) (PostgresT m) Unit
-> Producer (Maybe Buffer) (SessionT m) Unit
stdout q = do
pool <- lift ask
client <- lift $ RE.liftExcept $ hoist liftAff $ Pool.connect pool
client <- lift ask
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))
>-> Pipes.mapM releaseOnEOS