Skip to content

Runtime exception when foreign key is specified using Key Table instead of using TableId #786

@harendra-kumar

Description

@harendra-kumar

I have a schema which looks something like this:

share
    [ mkPersist sqlSettings ]
    [persistLowerCase|
RoleTable
    name  RoleName
    deriving Generic Show

UserTable
    roleId        (Key RoleTable)

This results in a runtime exception:

PersistMarshalError "field roleId: int64 Expected Integer, received: PersistText \"1\""

If I use RoleTableId instead of (Key RoleTable) in UserTable everything works fine. This is perhaps not an expected usage of the DSL but the error was not caught. Perhaps something went wrong in the TH code generation from the schema and it compiled fine but resulted in a runtime error. If that's the case then the schema DSL can perhaps be made a bit more robust against unexpected usage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions