-
Notifications
You must be signed in to change notification settings - Fork 301
Description
Issue
repsert works like so:
- Find record by ID
- If found, replace record for ID
- else, insert record with ID
repsertMany works like so:
- Find records by Ids
- new ids = given ids
difffound ids - insert records matching new ids
The following step is missing in repsertMany to make it symmetric with mapM_ (uncurry repsert):
- replace records matching found ids
Issue was introduced at the very conception of the feature, and there are no tests to verify this API.
Suggested fix
Since there is no batch means to add the missing step mentioned above, we should perhaps let each driver implement its own repsertMany natively akin to putMany; i.e., create a new field in SqlBackend called connRepsertManySql before letting each backend define it.
Bonus, this will actually address race condition errors/deadlocks arising from non-atomic client side operations (SELECT + INSERT) on the same table. I've run into parallel insert errors with repsertMany but never with the natively/atomically implemented putMany using Postgres 10.