I am using the yesod-sqlite template and trying to use the get function from Database.Persist in a test.
Here is my code:
[Entity _ task] <- runDB $ selectList [TaskName ==. name] []
...
user <- runDB $ X.get (taskUserId task)
And the error I am getting:
my_project/test/Handler/TaskSpec.hs:47:29: error:
Not in scope: ‘X.get’
No module named ‘X’ is imported.
In the TestImport.hs file, I saw this line:
import Database.Persist as X hiding (get)
To my understanding it should be hidding the get function from the HSpec module, so I could use X.get for database retrieving. I also tried with Database.Persist.get and just get with the same result.
So my doubt is: what that line in TestImport.hs is doing?
The import line is importing everything in the
Database.Persistmodule exceptget, optionally qualified.If I'm understanding correctly and you want to import only
getqualified, and everything else unqualified, you could use: