Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Export defaults

  • Loading branch information...
commit e1d1b6f6d47365e5890d1660c3798e36ca618ffb 1 parent 476112c
Leon P Smith authored
Showing with 18 additions and 9 deletions.
  1. +18 −9 src/Database/PostgreSQL/Simple.hs
27 src/Database/PostgreSQL/Simple.hs
View
@@ -88,6 +88,9 @@ module Database.PostgreSQL.Simple
, TransactionMode(..)
, IsolationLevel(..)
, ReadWriteMode(..)
+ , defaultTransactionMode
+ , defaultIsolationLevel
+ , defaultReadWriteMode
, withTransactionMode
-- , Base.autocommit
, begin
@@ -338,7 +341,7 @@ data FoldOptions
transactionMode :: !TransactionMode
}
-defaultFoldOptions = FoldOptions {
+defaultFoldOptions = FoldOptions {
fetchQuantity = Automatic,
transactionMode = TransactionMode ReadCommitted ReadOnly
}
@@ -493,14 +496,20 @@ data ReadWriteMode
| ReadOnly
deriving (Show, Eq, Ord, Enum, Bounded)
-data TransactionMode = TransactionMode {
- isolationLevel :: !IsolationLevel,
+data TransactionMode = TransactionMode {
+ isolationLevel :: !IsolationLevel,
readWriteMode :: !ReadWriteMode
- } deriving (Show, Eq, Ord)
+ } deriving (Show, Eq)
defaultTransactionMode :: TransactionMode
defaultTransactionMode = TransactionMode ReadCommitted ReadWrite
+defaultIsolationLevel :: IsolationLevel
+defaultIsolationLevel = ReadCommitted
+
+defaultReadWriteMode :: ReadWriteMode
+defaultReadWriteMode = ReadWrite
+
-- | Execute an action inside a SQL transaction.
--
-- This function initiates a transaction with a \"@begin
@@ -538,14 +547,14 @@ begin = beginMode defaultTransactionMode
beginMode :: TransactionMode -> Connection -> IO ()
beginMode mode conn = do
execute_ conn $! case mode of
- TransactionMode ReadCommitted ReadWrite ->
+ TransactionMode ReadCommitted ReadWrite ->
"BEGIN"
- TransactionMode ReadCommitted ReadOnly ->
+ TransactionMode ReadCommitted ReadOnly ->
"BEGIN READ ONLY"
- TransactionMode RepeatableRead ReadWrite ->
+ TransactionMode RepeatableRead ReadWrite ->
"BEGIN ISOLATION LEVEL REPEATABLE READ"
- TransactionMode RepeatableRead ReadOnly ->
- "BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY"
+ TransactionMode RepeatableRead ReadOnly ->
+ "BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY"
TransactionMode Serializable ReadWrite ->
"BEGIN ISOLATION LEVEL SERIALIZABLE"
TransactionMode Serializable ReadOnly ->
Please sign in to comment.
Something went wrong with that request. Please try again.