yesodweb / yesodweb/persistent
mpsPrefixFields = False breaks primary key configuration "Id <parameters...>"
Open
Nobody has claimed this yet.
bug
- Dominant language
- Haskell
- Stars
- 486
- Forks
- 306
- PR merge metrics
- No merged PRs in 30d
Description
Stack: LTS-9.21
OS: Ubuntu 14.4
backend: mysql
In the code below. Compilation fails if mpsPrefixFields is set to False. If set to True it succeeds.
share [mkPersist sqlSettings { mpsGenerateLenses = True, mpsPrefixFields = False }, mkMigrate "migrateAll"] [persistLowerCase|
Foo json
Id sql=REQ_ID
field1 String
field2 Int
deriving Show
|]
> stack build
servant-persistent-0.2.0.0: unregistering (local file changes: src/Models.hs)
servant-persistent-0.2.0.0: build (lib + exe)
Preprocessing library servant-persistent-0.2.0.0...
[4 of 6] Compiling Models ( src/Models.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/Models.o )
/home/someuser/Documents/src/labs/servant-persistent/src/Models.hs:31:1: error: Not in scope: data constructor ‘FooId’
-- While building package servant-persistent-0.2.0.0 using:
/home/someuser/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.24.2.0 build lib:servant-persistent exe:perservant --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
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 with src/Models.hs and reproduce the reported stack build using the shown persistent schema, mysql backend, and mpsPrefixFields = False. Trace the generated primary-key configuration around the reported FooId error and verify that the same schema compiles with the option disabled while retaining sql=REQ_ID.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell, mysql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100