yesodweb / yesodweb/persistent

Problems with BackendCompatible vs BaseBackend

Open
#822 9 comments 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

I'm attempting to update a codebase with heavy use of SqlReadT and SqlWriteT to latest LTS, which means v2.8.2 of persistent/persistent-postgresql. I'm running into the issue best described and reproduced in this minimal example:

https://gist.github.com/pbrisbin/47ad427ed4c421c21a29fff3a154e448

Here's what I think is happening:

  • sqlSettings creates an Entity with SqlBackend ref
  • selectList wants PersistRecordBackend record backend ref
  • We have type PersistRecordBackend record backend = (PersistEntity record, PersistEntityBackend record ~ BaseBackend backend) ref
  • So for this entity, that means BaseBackend backend ~ SqlBackend
  • SqlReadT no longer provides that, it only provides BackendCompatible SqlBackend backend ref ref

So I'm not sure if SqlBackendCanRead needs an update like I have in the gist (which is actually changing it back to what it was before), or PersistRecordBackend needs an update to use BackendCompatible, or if there's something else going on entirely.

If there's anything else about our code that we can change to make this work, that'd be appreciated, but moving from Sql(Read|Write)T to ReaderT backend so we can add these different constraints ourselves would be a very cumbersome upgrade path, so I'd love to avoid that.

Thank you in advance.

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

Compile the minimal example in the linked gist, then trace selectList, PersistRecordBackend, SqlReadT, SqlWriteT, and SqlBackendCanRead in the persistent packages. Determine which compatibility constraint should govern the example and verify the resolution against the reported upgrade path; the issue is done when the minimal reproduction works without requiring a cumbersome migration to ReaderT backend.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, sql
Domain
backend-api-design, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.