yesodweb / yesodweb/persistent

More general insertMany

Open
#878 4 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 wonder if it would be possible to make insertMany more general for the structure that contains the entities to be inserted. At the moment it's [record], but from what I can see the implementation doesn't need to specific to list. I believe it could be a combination of Traversable and Monoid.

I say Monoid because in the SqlBackend implementation it checks for an empty list and returns an empty list. This could be written as:

insertMany vals | null vals = return mempty

Then Traversable for the other case where mapM is used.

Maybe I'm missing something else. Let me know what you think :)

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 with persistent/Database/Persist/Sql/Orphan/PersistStore.hs around the insertMany implementation mentioned in the issue, then trace the shared insertMany definition and its type constraints. Compare the empty and non-empty cases across the relevant backends; done means the generalized structure is supported consistently without changing existing list behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
backend-api-design, database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.