yesodweb / yesodweb/persistent

mkPersist generates unbound type names since 2.14.3.2

Open
#1,467 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Haskell
Stars
486
Forks
306
PR merge metrics
No merged PRs in 30d

Description

There was a bug in #1446 that can result in mkPersist generating unbound type names. Tweaking the following test case very slightly reproduces the issue:

diff --git a/persistent/test/Database/Persist/TH/PersistWithSpec.hs b/persistent/test/Database/Persist/TH/PersistWithSpec.hs
index 25c9fff0..e006f65e 100644
--- a/persistent/test/Database/Persist/TH/PersistWithSpec.hs
+++ b/persistent/test/Database/Persist/TH/PersistWithSpec.hs
@@ -17,7 +17,7 @@ module Database.Persist.TH.PersistWithSpec where
 
 import Control.Monad
 import TemplateTestImports
-import Database.Persist.TH.PersistWith.Model as Model (IceCream, IceCreamId)
+import qualified Database.Persist.TH.PersistWith.Model as Model (IceCream, IceCreamId)
 import Language.Haskell.TH as TH
 
 mkPersistWith sqlSettings $(discoverEntities) [persistLowerCase|

The root issue is here:

https://github.com/yesodweb/persistent/blob/02b1f9fb951282b162bae5818446d020297eed5f/persistent/Database/Persist/TH.hs#L518

The first field of FTTypeCon can be a module prefix, but this code discards it, which results in unqualified references being generated in the output.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in persistent/Database/Persist/TH.hs around the referenced line, then reproduce the issue by applying the qualified import change in persistent/test/Database/Persist/TH/PersistWithSpec.hs. Confirm that mkPersist no longer emits unbound type names and that the affected test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.