Skip to content

Foreign syntax doesn't recognize tables in other modules #1073

@parsonsmatt

Description

@parsonsmatt

Suppose you have the following modules:

-- Schema/Foo.hs
module Schema.Foo where

mkPersist $(persistFileWith "foo.persistentmodels")

-- foo.persistentmodels
Foo
    name Text
    Primary name

-- Schema/Bar.hs

module Schema.Bar where

import Schema.Foo

mkPersist $(persistFileWith "bar.persistentmodels")

-- bar.persistentmodels
Bar
    foo Text
    Foreign Foo fk_bar_to_foo foo

This code will currently fail, because the HaskellName "Foo" is not present in the EmbedEntityMap, because it was not parsed from the same block of text.

I think there needs to be some way to lookup the entity without requiring it be present in the map. Attempting to call entityDef (Nothing :: Maybe $(Foo)) instead of relying on what's in the Map might work.

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