Coder Social home page Coder Social logo

pg-transact's Introduction

pg-transact Hackage CI

pg-transact's People

Contributors

jfischoff avatar tchoutri avatar

Stargazers

Brendan Houng avatar  avatar  avatar Daniel Kahlenberg avatar

Watchers

 avatar James Cloos avatar  avatar  avatar  avatar

pg-transact's Issues

Remove MonadThrow constraint from queryOne

First thanks for this nice little lib ๐Ÿ‘

In the latest version, queryOne and queryOne_ got introduced however they require a MonadThrow m whereas query does not.

This means that if I want to use queryOne in a function, I must add MonadThrow to that functions and all functions calling it.
I don't see any good reason to have MonadThrow in the first place, so do you think it would be possible to remove it?

Speed up the tests

The tests create way to many databases then appear necessary. Unsure of important it is to test transaction are committed in every test.

The interface should be build around a `MonadReader Connection m` monad

Not everything needs the DBT transactional semantics. postgresql-simple-queue does not need to use savepoints. I want to be able to code against an interface that can use DBT or something similar like ReaderT Conn IO which is probably a more performant monad for postgresql-simple-queue (assuming the savepoints are hurting performance).

Preparing pg-transact 0.3.2.0

With #19 merged, it may be time to think about a new release. pg-transact-hspec will need this patch for its own CI.

@jfischoff Is there anything you'd like to make sure we include in this release?

Test failures on Stackage nightly

Full log

Database.PostgreSQL.Transact
  TransactionSpec
    execute_ happen path succeeds FAILED [1]
    execute_ rollbacks on exception
     # PENDING: exception in beforeAll-hook (see previous failure)
    afterAll-hook FAILED [2]
    multiple execute_'s succeed FAILED [3]
    throwM causes a rollback FAILED [4]
    query recovers when exception is caught FAILED [5]
    multiple catch statements work correctly FAILED [6]
    alternate branches can also have savepoints FAILED [7]
    releasing silently fails if the transaction errors FAILED [8]

Failures:

  test/Database/PostgreSQL/TransactSpec.hs:65: 
  1) Database.PostgreSQL.Transact.TransactionSpec execute_ happen path succeeds
       uncaught exception: IOException of type UserError (user error (Pattern match failure in do expression at test/Database/PostgreSQL/TransactSpec.
hs:24:5-16))

  2) Database.PostgreSQL.Transact.TransactionSpec afterAll-hook
       uncaught exception: Result (Pending (Just "exception in beforeAll-hook (see previous failure)"))

  test/Database/PostgreSQL/TransactSpec.hs:82: 
  3) Database.PostgreSQL.Transact.TransactionSpec multiple execute_'s succeed
       uncaught exception: IOException of type UserError (user error (Pattern match failure in do expression at test/Database/PostgreSQL/TransactSpec.hs:24:5-16))

  test/Database/PostgreSQL/TransactSpec.hs:89: 
  4) Database.PostgreSQL.Transact.TransactionSpec throwM causes a rollback
       uncaught exception: IOException of type UserError (user error (Pattern match failure in do expression at test/Database/PostgreSQL/TransactSpec.hs:24:5-16))

  test/Database/PostgreSQL/TransactSpec.hs:98: 
  5) Database.PostgreSQL.Transact.TransactionSpec query recovers when exception is caught
       uncaught exception: IOException of type UserError (user error (Pattern match failure in do expression at test/Database/PostgreSQL/TransactSpec.hs:24:5-16))

  test/Database/PostgreSQL/TransactSpec.hs:108: 
  6) Database.PostgreSQL.Transact.TransactionSpec multiple catch statements work correctly
       uncaught exception: IOException of type UserError (user error (Pattern match failure in do expression at test/Database/PostgreSQL/TransactSpec.hs:24:5-16))

  test/Database/PostgreSQL/TransactSpec.hs:121: 
  7) Database.PostgreSQL.Transact.TransactionSpec alternate branches can also have savepoints
       uncaught exception: IOException of type UserError (user error (Pattern match failure in do expression at test/Database/PostgreSQL/TransactSpec.hs:24:5-16))

  test/Database/PostgreSQL/TransactSpec.hs:133: 
  8) Database.PostgreSQL.Transact.TransactionSpec releasing silently fails if the transaction errors
       uncaught exception: IOException of type UserError (user error (Pattern match failure in do expression at test/Database/PostgreSQL/TransactSpec.hs:24:5-16))

Randomized with seed 1794480295

`MonadError` instance

I've found myself needing to interleave the possiblity of errors within DBT. For now, I use lift . throwError to throw errors, and use runExceptT just before running the transaction.

Implementing MonadError e m => MonadError e (DBT m) is trivial (with GeneralizedNewtypeDeriving for instance), but I'm not 100% sure about the semantics wrt transactions.

Do you think such an instance would make sense, or that it would give rise to dangerous things?
If it makes sense, I can open a PR to add it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.