yesodweb / yesodweb/persistent

`upsertWhere` in `Database.Persist.Postgresql` has too strict a type signature

Open
#1,489 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Haskell
Stars
486
Forks
306
PR merge metrics
No merged PRs in 30d

Description

The constraints for upsertWhere are as follows:

( backend ~ PersistEntityBackend record
, PersistEntity record
, PersistEntityBackend record ~ SqlBackend
, MonadIO m
, PersistStore backend
, BackendCompatible SqlBackend backend
, OnlyOneUniqueKey record
) =>

But as you might notice, it's saying BackendCompatible SqlBackend backend AND backend ~ SqlBackend (via a small detour using PersistEntityBackend record).
So it's basically just saying the backend HAS to be SqlBackend. I believe this should be able to be loosened (so we can use our own backend)

At first glance, I think the backend ~ PersistEntityBackend record is the only unnecessary constraint. 🤔

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at upsertWhere in Database.Persist.Postgresql and trace how PersistEntityBackend, SqlBackend, and BackendCompatible constrain the function. Confirm the intended custom-backend use and update coverage so the signature permits it without forcing backend ~ SqlBackend.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, postgresql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.