Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deserializing to Markdown fails because a PersistByteString is passed #12

Open
MaxGabriel opened this issue Aug 14, 2015 · 2 comments
Open

Comments

@MaxGabriel
Copy link
Contributor

It looks like yesod-text-markdown isn't able to deserialize what was inserted; fromPersistValue is passed a PersistByteString when yesod-text-markdown requires a PersistText. This can be reproduced like so :

  1. Create a new scaffolded MySQL project (I used yesod-bin 1.4.13.3)

  2. Add the markdown and yesod-text-markdown packages to build-depends in the Cabal file (I used the versions from LTS Haskell 2.17).

  3. Add these imports to Model.hs:

    import Text.Markdown (Markdown)
    import Yesod.Text.Markdown ()
  4. Add this model to config/models:

    BlogPost
        title Text
        article Markdown
    
  5. Start a GHCi session and run the following code:

    ghci > db $ insert (BlogPost "title" "article")
    ghci > import Database.Persist.Sql
    ghci > db $ get (toSqlKey 1 :: BlogPostId)
    14/Aug/2015:08:49:59 -0700 [Debug#SQL] SELECT `title`,`article` FROM `blog_post` WHERE `id`=?; [PersistInt64 1]
    *** Exception: runFakeHandler issue: InternalError "get BlogPostKey {unBlogPostKey = SqlBackendKey {unSqlBackendKey = 1}}: field article: Not a PersistText value"
    

(I think this can be reproduced easily in a script/test; I'll try to write one up)

These two StackOverflow questions reported the issue:

This might be a bug in Persistent; I'm still investigating.

@Tarrasch
Copy link
Owner

Thanks for creating the issue. It was so long time ago I used Yesod though, I think you'll have to investigate on your own :-/.

Anyway, I'm happy to merge PRs and upload fixes :)

@MaxGabriel
Copy link
Contributor Author

@Tarrasch No problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants