diff --git a/ChangeLog.md b/ChangeLog.md
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,3 +1,8 @@
+## 2.1.5
+
+Add `dbIdColumnsEsc` to Sql.Utils.
+Used in persistent-postgresql 2.1.5.2
+
 ## 2.1.4
 
 * Fix getBy with a primary key. #342
diff --git a/Database/Persist/Sql/Util.hs b/Database/Persist/Sql/Util.hs
--- a/Database/Persist/Sql/Util.hs
+++ b/Database/Persist/Sql/Util.hs
@@ -6,6 +6,7 @@
   , isIdField
   , hasCompositeKey
   , dbIdColumns
+  , dbIdColumnsEsc
   , dbColumns
 ) where
 
@@ -16,7 +17,8 @@
     Entity(Entity), EntityDef, EntityField, HaskellName(HaskellName)
   , PersistEntity, PersistValue, PersistException(PersistMarshalError)
   , keyFromValues, fromPersistValues, fieldDB, entityId, entityPrimary
-  , entityFields, fieldHaskell, compositeFields, persistFieldDef)
+  , entityFields, fieldHaskell, compositeFields, persistFieldDef
+  , DBName)
 import Database.Persist.Sql.Types (Sql, SqlBackend, connEscapeName)
 import Control.Monad.IO.Class (MonadIO(liftIO))
 import Control.Exception (throwIO)
@@ -35,9 +37,12 @@
 hasCompositeKey = isJust . entityPrimary
 
 dbIdColumns :: SqlBackend -> EntityDef -> [Text]
-dbIdColumns conn t = case entityPrimary t of
-    Just pdef -> map (connEscapeName conn . fieldDB) $ compositeFields pdef
-    Nothing   -> [connEscapeName conn $ fieldDB (entityId t)]
+dbIdColumns conn = dbIdColumnsEsc (connEscapeName conn)
+
+dbIdColumnsEsc :: (DBName -> Text) -> EntityDef -> [Text]
+dbIdColumnsEsc esc t = case entityPrimary t of
+    Just pdef -> map (esc . fieldDB) $ compositeFields pdef
+    Nothing   -> [esc $ fieldDB (entityId t)]
 
 dbColumns :: SqlBackend -> EntityDef -> [Text]
 dbColumns conn t = case entityPrimary t of
diff --git a/persistent.cabal b/persistent.cabal
--- a/persistent.cabal
+++ b/persistent.cabal
@@ -1,5 +1,5 @@
 name:            persistent
-version:         2.1.4
+version:         2.1.5
 license:         MIT
 license-file:    LICENSE
 author:          Michael Snoyman <michael@snoyman.com>
