Skip to content

ID fields can sometimes be generated with ForeignRefs #1615

@hdgarrood

Description

@hdgarrood

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions