Merge pull request #106 from thiagorp/master

Add `FOR UPDATE SKIP LOCKED` to possible lock types and fix CI
This commit is contained in:
Chris Allen 2018-12-18 14:09:13 -06:00 committed by GitHub
commit 5f98e7b253
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 8 deletions

View File

@ -28,6 +28,7 @@ install:
- stack --version
- echo "CREATE USER esqutest WITH PASSWORD 'esqutest';" | psql postgres
- createdb -O esqutest esqutest
- mysql -e 'CREATE DATABASE esqutest;'
script:
- stack setup

View File

@ -829,6 +829,11 @@ data LockingKind =
-- PostgreSQL.
--
-- /Since: 2.2.7/
| ForUpdateSkipLocked
-- ^ @FOR UPDATE SKIP LOCKED@ syntax. Supported by MySQL, Oracle and
-- PostgreSQL.
--
-- /Since: 2.2.7/
| ForShare
-- ^ @FOR SHARE@ syntax. Supported by PostgreSQL.
--

View File

@ -1212,9 +1212,10 @@ makeLimit (conn, _) (Limit ml mo) orderByClauses =
makeLocking :: LockingClause -> (TLB.Builder, [PersistValue])
makeLocking = flip (,) [] . maybe mempty toTLB . Monoid.getLast
where
toTLB ForUpdate = "\nFOR UPDATE"
toTLB ForShare = "\nFOR SHARE"
toTLB LockInShareMode = "\nLOCK IN SHARE MODE"
toTLB ForUpdate = "\nFOR UPDATE"
toTLB ForUpdateSkipLocked = "\nFOR UPDATE SKIP LOCKED"
toTLB ForShare = "\nFOR SHARE"
toTLB LockInShareMode = "\nLOCK IN SHARE MODE"

View File

@ -1337,9 +1337,10 @@ testLocking withConn = do
let expected = complex <> "\n" <> syntax
(with1, with2, with3) `shouldBe` (expected, expected, expected)
it "looks sane for ForUpdate" $ sanityCheck ForUpdate "FOR UPDATE"
it "looks sane for ForShare" $ sanityCheck ForShare "FOR SHARE"
it "looks sane for LockInShareMode" $ sanityCheck LockInShareMode "LOCK IN SHARE MODE"
it "looks sane for ForUpdate" $ sanityCheck ForUpdate "FOR UPDATE"
it "looks sane for ForUpdateSkipLocked" $ sanityCheck ForUpdateSkipLocked "FOR UPDATE SKIP LOCKED"
it "looks sane for ForShare" $ sanityCheck ForShare "FOR SHARE"
it "looks sane for LockInShareMode" $ sanityCheck LockInShareMode "LOCK IN SHARE MODE"

View File

@ -212,7 +212,7 @@ withConn =
R.runResourceT .
withMySQLConn defaultConnectInfo
{ connectHost = "localhost"
, connectUser = "esqutest"
, connectPassword = "esqutest"
, connectUser = "travis"
, connectPassword = ""
, connectDatabase = "esqutest"
}