jfischoff / pg-transact Goto Github PK
View Code? Open in Web Editor NEWAnother postgresql-simple transaction monad
License: Other
Another postgresql-simple transaction monad
License: Other
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?
It is annoying to not be able to user shouldThrow
directly in the DBT monad.
The tests create way to many databases then appear necessary. Unsure of important it is to test transaction are committed in every test.
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).
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?
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
This is key advantage to rollback
compared to abort
. I should test it works ... since I am documenting that it works.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.