diff --git a/.travis.yml b/.travis.yml index 0655e70..62f4a71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/src/Database/Esqueleto/Internal/Language.hs b/src/Database/Esqueleto/Internal/Language.hs index b8d98d5..ac992e1 100644 --- a/src/Database/Esqueleto/Internal/Language.hs +++ b/src/Database/Esqueleto/Internal/Language.hs @@ -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. -- diff --git a/src/Database/Esqueleto/Internal/Sql.hs b/src/Database/Esqueleto/Internal/Sql.hs index e13877a..16a24e9 100644 --- a/src/Database/Esqueleto/Internal/Sql.hs +++ b/src/Database/Esqueleto/Internal/Sql.hs @@ -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" diff --git a/test/Common/Test.hs b/test/Common/Test.hs index a513a29..34c9c87 100644 --- a/test/Common/Test.hs +++ b/test/Common/Test.hs @@ -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" diff --git a/test/MySQL/Test.hs b/test/MySQL/Test.hs index 1aa6356..0b3a53c 100644 --- a/test/MySQL/Test.hs +++ b/test/MySQL/Test.hs @@ -212,7 +212,7 @@ withConn = R.runResourceT . withMySQLConn defaultConnectInfo { connectHost = "localhost" - , connectUser = "esqutest" - , connectPassword = "esqutest" + , connectUser = "travis" + , connectPassword = "" , connectDatabase = "esqutest" }