diff --git a/ChangeLog.md b/ChangeLog.md
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,5 +1,9 @@
 # Changelog for persistent
 
+## 2.10.1
+
+* Added `constraint=` attribute to allow users to specify foreign reference constraint names.
+
 ## 2.10.0
 
 * Added two type classes `OnlyOneUniqueKey` and `AtLeastOneUniqueKey`. These classes are used as constraints on functions that expect a certain amount of unique keys. They are defined automatically as part of the `persistent-template`'s generation. [#885](https://github.com/yesodweb/persistent/pull/885)
diff --git a/Database/Persist/Class/PersistEntity.hs b/Database/Persist/Class/PersistEntity.hs
--- a/Database/Persist/Class/PersistEntity.hs
+++ b/Database/Persist/Class/PersistEntity.hs
@@ -134,6 +134,12 @@
 -- and the argument for the comparison.
 --
 -- Persistent users use combinators to create these.
+--
+-- Note that it's important to be careful about the 'PersistFilter' that
+-- you are using, if you use this directly. For example, using the 'In'
+-- 'PersistFilter' requires that you have an array- or list-shaped
+-- 'EntityField'. It is possible to construct values using this that will
+-- create malformed runtime values.
 data Filter record = forall typ. PersistField typ => Filter
     { filterField  :: EntityField record typ
     , filterValue  :: FilterValue typ
diff --git a/Database/Persist/Sql/Internal.hs b/Database/Persist/Sql/Internal.hs
--- a/Database/Persist/Sql/Internal.hs
+++ b/Database/Persist/Sql/Internal.hs
@@ -61,9 +61,13 @@
             Just (resolveTableName allDefs f, refName tn c)
         | otherwise = Nothing
     ref _ _ ("noreference":_) = Nothing
-    ref c _ (a:_)
-        | Just x <- T.stripPrefix "reference=" a =
-            Just (DBName x, refName tn c)
+    ref c fe (a:as)
+        | Just x <- T.stripPrefix "reference=" a = do
+            constraintName <- snd <$> (ref c fe as)
+            pure (DBName x, constraintName)
+        | Just x <- T.stripPrefix "constraint=" a = do
+            tableName <- fst <$> (ref c fe as)
+            pure (tableName, DBName x)
     ref c x (_:as) = ref c x as
 
 refName :: DBName -> DBName -> DBName
diff --git a/Database/Persist/Sql/Orphan/PersistQuery.hs b/Database/Persist/Sql/Orphan/PersistQuery.hs
--- a/Database/Persist/Sql/Orphan/PersistQuery.hs
+++ b/Database/Persist/Sql/Orphan/PersistQuery.hs
@@ -343,8 +343,8 @@
                 else id)
             $ connEscapeName conn $ fieldName field
         qmarks = case value of
-                    FilterValue{} -> "?"
-                    UnsafeValue{} -> "?"
+                    FilterValue{} -> "(?)"
+                    UnsafeValue{} -> "(?)"
                     FilterValues xs ->
                         let parens a = "(" <> a <> ")"
                             commas = T.intercalate ","
diff --git a/persistent.cabal b/persistent.cabal
--- a/persistent.cabal
+++ b/persistent.cabal
@@ -1,5 +1,5 @@
 name:            persistent
-version:         2.10.0
+version:         2.10.1
 license:         MIT
 license-file:    LICENSE
 author:          Michael Snoyman <michael@snoyman.com>
