Skip to content

Commit 81047ec

Browse files
committed
Improve error messages around getBy with NULLABLE fields
1 parent f4176c5 commit 81047ec

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

persistent/Database/Persist/Class/PersistUnique.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ import Database.Persist.Types
5757
class (PersistStoreRead backend) => PersistUniqueRead backend where
5858
-- | Get a record by unique key, if available. Returns also the identifier.
5959
--
60+
-- If your unique key contains a nullable field, then, by default, getBy will not match if any of the fields are NULL.
61+
--
6062
-- === __Example usage__
6163
--
6264
-- With <#schema-persist-unique-1 schema-1> and <#dataset-persist-unique-1 dataset-1>:

persistent/Database/Persist/TH/Internal.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1524,7 +1524,8 @@ mkUnique mps entityMap entDef (UniqueDef constr _ fields attrs) =
15241524
, "column in question. If you understand this feature of SQL and still "
15251525
, "intend to add a uniqueness constraint here, *** Use a \"!force\" "
15261526
, "attribute on the end of the line that defines your uniqueness "
1527-
, "constraint in order to disable this check. ***"
1527+
, "constraint in order to disable this check. ***\n"
1528+
, "By default, this means using `getBy`, `insertBy`, or anything that fetches by unique key will NOT match if any of the fields are NULL."
15281529
]
15291530

15301531
-- | This function renders a Template Haskell 'Type' for an 'UnboundFieldDef'.

0 commit comments

Comments
 (0)