Skip to content
This repository
Browse code

Export defaults

  • Loading branch information...
commit e1d1b6f6d47365e5890d1660c3798e36ca618ffb 1 parent 476112c
Leon P Smith authored

Showing 1 changed file with 18 additions and 9 deletions. Show diff stats Hide diff stats

  1. +18 9 src/Database/PostgreSQL/Simple.hs
27 src/Database/PostgreSQL/Simple.hs
@@ -88,6 +88,9 @@ module Database.PostgreSQL.Simple
88 88 , TransactionMode(..)
89 89 , IsolationLevel(..)
90 90 , ReadWriteMode(..)
  91 + , defaultTransactionMode
  92 + , defaultIsolationLevel
  93 + , defaultReadWriteMode
91 94 , withTransactionMode
92 95 -- , Base.autocommit
93 96 , begin
@@ -338,7 +341,7 @@ data FoldOptions
338 341 transactionMode :: !TransactionMode
339 342 }
340 343
341   -defaultFoldOptions = FoldOptions {
  344 +defaultFoldOptions = FoldOptions {
342 345 fetchQuantity = Automatic,
343 346 transactionMode = TransactionMode ReadCommitted ReadOnly
344 347 }
@@ -493,14 +496,20 @@ data ReadWriteMode
493 496 | ReadOnly
494 497 deriving (Show, Eq, Ord, Enum, Bounded)
495 498
496   -data TransactionMode = TransactionMode {
497   - isolationLevel :: !IsolationLevel,
  499 +data TransactionMode = TransactionMode {
  500 + isolationLevel :: !IsolationLevel,
498 501 readWriteMode :: !ReadWriteMode
499   - } deriving (Show, Eq, Ord)
  502 + } deriving (Show, Eq)
500 503
501 504 defaultTransactionMode :: TransactionMode
502 505 defaultTransactionMode = TransactionMode ReadCommitted ReadWrite
503 506
  507 +defaultIsolationLevel :: IsolationLevel
  508 +defaultIsolationLevel = ReadCommitted
  509 +
  510 +defaultReadWriteMode :: ReadWriteMode
  511 +defaultReadWriteMode = ReadWrite
  512 +
504 513 -- | Execute an action inside a SQL transaction.
505 514 --
506 515 -- This function initiates a transaction with a \"@begin
@@ -538,14 +547,14 @@ begin = beginMode defaultTransactionMode
538 547 beginMode :: TransactionMode -> Connection -> IO ()
539 548 beginMode mode conn = do
540 549 execute_ conn $! case mode of
541   - TransactionMode ReadCommitted ReadWrite ->
  550 + TransactionMode ReadCommitted ReadWrite ->
542 551 "BEGIN"
543   - TransactionMode ReadCommitted ReadOnly ->
  552 + TransactionMode ReadCommitted ReadOnly ->
544 553 "BEGIN READ ONLY"
545   - TransactionMode RepeatableRead ReadWrite ->
  554 + TransactionMode RepeatableRead ReadWrite ->
546 555 "BEGIN ISOLATION LEVEL REPEATABLE READ"
547   - TransactionMode RepeatableRead ReadOnly ->
548   - "BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY"
  556 + TransactionMode RepeatableRead ReadOnly ->
  557 + "BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY"
549 558 TransactionMode Serializable ReadWrite ->
550 559 "BEGIN ISOLATION LEVEL SERIALIZABLE"
551 560 TransactionMode Serializable ReadOnly ->

0 comments on commit e1d1b6f

Please sign in to comment.
Something went wrong with that request. Please try again.