yesodweb / yesodweb/persistent
ID fields can sometimes be generated with ForeignRefs
Open
Nobody has claimed this yet.
- Dominant language
- Haskell
- Stars
- 486
- Forks
- 306
- PR merge metrics
- No merged PRs in 30d
Description
For example:
ExplicitPrimaryKey sql=explicit_primary_key
Id Text
produces an EntityDef of
EntityDef
{ entityHaskell = EntityNameHS{unEntityNameHS = "ExplicitPrimaryKey"}
, entityDB = EntityNameDB{unEntityNameDB = "explicit_primary_key"}
, entityId =
EntityIdField
( FieldDef
{ fieldHaskell = FieldNameHS{unFieldNameHS = "Id"}
, fieldDB = FieldNameDB{unFieldNameDB = "id"}
, fieldType = FTTypeCon Nothing "Text"
, fieldSqlType = SqlString
, fieldAttrs = [FieldAttrOther "Text"]
, fieldStrict = False
, fieldReference =
ForeignRef (EntityNameHS{unEntityNameHS = "ExplicitPrimaryKey"})
, fieldCascade = FieldCascade{fcOnUpdate = Nothing, fcOnDelete = Nothing}
, fieldComments = Nothing
, fieldGenerated = Nothing
, fieldIsImplicitIdColumn = True
}
)
, [...]
}
I would expect fieldReference = NoReference here - it doesn't really make sense for an entity's ID field to be a reference to itself.
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
Start by locating the code that generates EntityDef values for implicit ID fields and reproducing the ExplicitPrimaryKey example from the issue. Trace why the ID receives a ForeignRef to its own entity; done means the generated fieldReference is NoReference for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100