Skip to content

Commit

Permalink
Deprecate LockingKind constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
parsonsmatt committed Dec 27, 2024
1 parent 339f66a commit 44428af
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Database/Esqueleto.hs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ module Database.Esqueleto {-# WARNING "This module will switch over to the Exper
, OrderBy
, DistinctOn
, LockingKind(..)
, forUpdate
, forUpdateSkipLocked
, LockableEntity(..)
, SqlString
-- ** Joins
Expand Down
2 changes: 2 additions & 0 deletions src/Database/Esqueleto/Experimental.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ module Database.Esqueleto.Experimental
, distinctOnOrderBy
, having
, locking
, forUpdate
, forUpdateSkipLocked

, (^.)
, (?.)
Expand Down
26 changes: 26 additions & 0 deletions src/Database/Esqueleto/Internal/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,32 @@ data LockingKind
--
-- @since 2.2.7

{-# DEPRECATED ForUpdate, ForUpdateSkipLocked "The constructors for 'LockingKind' are deprecated in v3.6.0.0. Instead, please refer to the smart constructors 'forUpdate' and 'forUpdateSkipLocked'." #-}
{-# DEPRECATED ForShare "The constructors for 'LockingKind' are deprecated in v3.6.0.0. Instead, please refer to the smart constructor 'forShare' exported from Database.Esqueleto.PostgreSQL." #-}
{-# DEPRECATED LockInShareMode "The constructors for 'LockingKind' are deprecated in v3.6.0.0. Instead, please refer to the smart constructors 'lockInShareMode' exported from Database.Esqueleto.MySQL." #-}

-- | @FOR UPDATE@ syntax.
--
-- Usage:
--
-- @
-- 'locking' 'forUpdate'
-- @
--
-- @since 3.6.0.0
forUpdate :: LockingKind
forUpdate = ForUpdate

-- | @FOR UPDATE SKIP LOCKED@ syntax.
--
-- @
-- 'locking' 'forUpdateSkipLocked'
-- @
--
-- @since 3.6.0.0
forUpdateSkipLocked :: LockingKind
forUpdateSkipLocked = ForUpdateSkipLocked

-- | Postgres specific locking, used only internally
--
-- @since 3.5.9.0
Expand Down
2 changes: 2 additions & 0 deletions src/Database/Esqueleto/Legacy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ module Database.Esqueleto.Legacy
, OrderBy
, DistinctOn
, LockingKind(..)
, forUpdate
, forUpdateSkipLocked
, LockableEntity(..)
, SqlString
-- ** Joins
Expand Down
15 changes: 14 additions & 1 deletion src/Database/Esqueleto/MySQL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
-- @since 2.2.8
module Database.Esqueleto.MySQL
( random_
, lockInShareMode
) where

import Database.Esqueleto.Internal.Internal hiding (random_)

Check warning on line 11 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.8)

Module ‘Database.Esqueleto.Internal.Internal’ does not export ‘random_’.

Check warning on line 11 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.8)

Module ‘Database.Esqueleto.Internal.Internal’ does not export ‘random_’.

Check warning on line 11 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.10)

Module ‘Database.Esqueleto.Internal.Internal’ does not export ‘random_’.

Check warning on line 11 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.10)

Module ‘Database.Esqueleto.Internal.Internal’ does not export ‘random_’.

Check warning on line 11 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 8.6)

Module

Check warning on line 11 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.0)

Module

Check warning on line 11 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.0)

Module

Check warning on line 11 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 8.10)

Module

Check warning on line 11 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 8.10)

Module

Check warning on line 11 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.2)

Module

Check warning on line 11 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.2)

Module

Check warning on line 11 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 8.8)

Module

Check warning on line 11 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 8.8)

Module

Check warning on line 11 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.4)

Module

Check warning on line 11 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.4)

Module

Check warning on line 11 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.6)

Module

Check warning on line 11 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.6)

Module
Expand All @@ -13,6 +14,18 @@ import Database.Esqueleto.Internal.PersistentImport
-- | (@random()@) Split out into database specific modules
-- because MySQL uses `rand()`.
--
-- /Since: 2.6.0/
-- @since 2.6.0
random_ :: (PersistField a, Num a) => SqlExpr (Value a)
random_ = unsafeSqlValue "RAND()"

-- | @LOCK IN SHARE MODE@ syntax.
--
-- Example:
--
-- @
-- 'locking' 'lockInShareMode'
-- @
--
-- @since 3.6.0.0
lockInShareMode :: LockingKind
lockInShareMode = LockInShareMode

Check warning on line 31 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.8)

In the use of data constructor ‘LockInShareMode’

Check warning on line 31 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.8)

In the use of data constructor ‘LockInShareMode’

Check warning on line 31 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.10)

In the use of data constructor ‘LockInShareMode’

Check warning on line 31 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.10)

In the use of data constructor ‘LockInShareMode’

Check warning on line 31 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 8.6)

In the use of data constructor ‘LockInShareMode’

Check warning on line 31 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.0)

In the use of data constructor ‘LockInShareMode’

Check warning on line 31 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.0)

In the use of data constructor ‘LockInShareMode’

Check warning on line 31 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 8.10)

In the use of data constructor ‘LockInShareMode’

Check warning on line 31 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 8.10)

In the use of data constructor ‘LockInShareMode’

Check warning on line 31 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.2)

In the use of data constructor ‘LockInShareMode’

Check warning on line 31 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.2)

In the use of data constructor ‘LockInShareMode’

Check warning on line 31 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 8.8)

In the use of data constructor ‘LockInShareMode’

Check warning on line 31 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 8.8)

In the use of data constructor ‘LockInShareMode’

Check warning on line 31 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.4)

In the use of data constructor ‘LockInShareMode’

Check warning on line 31 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.4)

In the use of data constructor ‘LockInShareMode’

Check warning on line 31 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.6)

In the use of data constructor ‘LockInShareMode’

Check warning on line 31 in src/Database/Esqueleto/MySQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 9.6)

In the use of data constructor ‘LockInShareMode’
13 changes: 13 additions & 0 deletions src/Database/Esqueleto/PostgreSQL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module Database.Esqueleto.PostgreSQL
, skipLocked
, forUpdateOf
, forNoKeyUpdateOf
, forShare
, forShareOf
, forKeyShareOf
, filterWhere
Expand Down Expand Up @@ -654,6 +655,18 @@ forShareOf :: LockableEntity a => a -> OnLockedBehavior -> SqlQuery ()
forShareOf lockableEntities onLockedBehavior =
putLocking $ PostgresLockingClauses [PostgresLockingKind PostgresForShare (Just $ LockingOfClause lockableEntities) onLockedBehavior]

-- | @FOR SHARE@ syntax for Postgres locking.
--
-- Example use:
--
-- @
-- 'locking' 'forShare'
-- @
--
-- @since 3.6.0.0
forShare :: LockingKind
forShare = ForShare

Check warning on line 668 in src/Database/Esqueleto/PostgreSQL.hs

View workflow job for this annotation

GitHub Actions / build (3.10.2.1, 8.6)

In the use of data constructor ‘ForShare’

-- | `FOR KEY SHARE OF` syntax for postgres locking
-- allows locking of specific tables with a key share lock in a view or join
--
Expand Down

0 comments on commit 44428af

Please sign in to comment.