lykahb / groundhog

This library maps datatypes to a relational model, in a way similar to what ORM libraries do in OOP. See the tutorial https://www.schoolofhaskell.com/user/lykahb/groundhog for introduction
http://hackage.haskell.org/package/groundhog
176 stars 39 forks source link

Key on embedded field #99

Open yaitskov opened 3 years ago

yaitskov commented 3 years ago
data T1 = T1 { _t1_F1 :: Int }

data T2 = T2 { _t2_F2 :: T1 }

mkPersist(defaultCodegenConfig { namingStyle = escapeUnderscore })
  [groundhog|
definitions:
  - entity: T2
    dbName: t2
    autoKey: null
    keys:
      - name: Xxx
        default: true
    constructors:
      - name: T2
        uniques:
          - name: Xxx
            type: primary
            fields: [_t2_F2._t1_F1]
|]
    Exception when trying to run compile-time code:
      Not found field with name "_t2_F2._t1_F1"