yesodweb / yesodweb/persistent
Allow intentionally defining an `id` field
Nobody has claimed this yet.
- Dominant language
- Haskell
- Stars
- 486
- Forks
- 306
- PR merge metrics
- No merged PRs in 30d
Description
I would like to allow defining the following:
User
id Int64
...
Primary ...
-
This should suppress all the existing magic such as generating a
UserIdtype. -
UserIdwould be anEntityField User Int64. -
The
Usertype would include auserId :: Int64field. -
All the
Key-based stuff would be based on thePrimaryfield.
As I have used persistent more and more, I have noticed that a lot of the pain points are either due to not being able to treat regular fields more like id, or due to not being able to treat id more like a regular field. So I would like to slowly unify id with other fields in a backwards compatible way.
This change in isolation is less useful than it will be after changes like #995 are implemented, but I similarly think that #995 is less useful without this change. So I think it makes sense to implement this first in isolation.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are named in the issue. Start by tracing how Persistent currently handles generated IDs, EntityField types, user record fields, and Primary/Key behavior, then compare the desired model with the related changes in #995. Done means intentionally defining an id field works without the existing generated-ID magic while preserving backwards compatibility.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100