File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 11# Revision history for Entity
22
3+ ## 0.0.7.0 -- XXXX-XX-XX
4+
5+ * Add ` _onConflictDoNothing `
6+
37## 0.0.6.0 -- 2025-05-20
48
59* The ` prod ` flag is removed, end of the experiment. End-users should be in charge of logging the queries.
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ module Database.PostgreSQL.Entity
3838 , insert
3939 , insertMany
4040 , upsert
41+ , upsertOnPK_
4142
4243 -- ** Update
4344 , update
@@ -280,7 +281,7 @@ insert
280281 -> DBT m ()
281282insert fs = void $ execute (_insert @ e ) fs
282283
283- {-| Insert an entity with a "ON CONFLICT DO UPDATE" clause on the primary key as the conflict target
284+ {-| Insert an entity with an "ON CONFLICT DO UPDATE" clause on the primary key as the conflict target
284285
285286 @since 0.0.2.0
286287-}
@@ -296,6 +297,20 @@ upsert entity fieldsToReplace = void $ execute (_insert @e <> _onConflictDoUpdat
296297 where
297298 conflictTarget = V. singleton $ primaryKey @ e
298299
300+ {-| Insert an entity with an "ON CONFLICT DO NOTHING" clause
301+
302+ @since 0.0.2.0
303+ -}
304+ upsertOnPK_
305+ :: forall e values m
306+ . (Entity e , ToRow values , MonadIO m )
307+ => values
308+ -- ^ Entity to insert
309+ -> DBT m ()
310+ upsertOnPK_ entity = void $ execute (_insert @ e <> _onConflictDoNothing conflictTarget ) entity
311+ where
312+ conflictTarget = V. singleton $ primaryKey @ e
313+
299314{-| Insert multiple rows of an entity.
300315
301316 @since 0.0.2.0
You can’t perform that action at this time.
0 commit comments