Skip to content

PersistMarshalError with UTCTime on Sqlite #339

Description

@nek0

Hello,

I have encountered a problem after migrating my project eidolon to persistent > 2.0. At runtime yesod throws errors like

PersistMarshalError "field time: Expected UTCTime, received PersistText \"2014-12-23T04:01:11.786518\""

although the whole project compiles without errors. Can you help me out, please?

Activity

  1. snoyberg commented on Dec 23, 2014

    @snoyberg
    Member

    Can you tell me the exact version of persistent-sqlite you're using? And it would be great to see a short code snippet that reproduces the problem.

  2. nek0 commented on Dec 23, 2014

    @nek0
    Author

    I am currently using persistent-2.1.1.2 and persistent-sqlite-2.1.1.1 in a sandbox.

    in my config/models file I have a section, where I define a datatype storing a timestamp in UTCTime

    Medium
        title Text
        path FP.FilePath
        thumb FP.FilePath
        mime Text
        time UTCTime
        owner UserId
        description Textarea
        tags Texts
        album AlbumId
        deriving Eq Show
    

    One line of code that prodces the is fore example in Handler/Home.hs of my aforementioned project, where I access all media and sort them by timestamp:

    recentMedia <- runDB $ selectList [] [Desc MediumTime]
    

    When accessing a single medium with

    tempMedium <- runDB $ get mediumId
    

    the server will throw a similar error:

    get MediumKey {unMediumKey = SqlBackendKey {unSqlBackendKey = 1}}: field time: Expected UTCTime, received PersistText "2014-12-23T04:01:11.786518"
    

    I hope this clarifies the problem I encounter.

  3. snoyberg commented on Dec 23, 2014

    @snoyberg
    Member

    And I'm guessing you're loading up data that was written by a previous
    version of persistent, correct? Does the problem occur with a fresh
    database?

    On Tue, Dec 23, 2014, 11:45 AM rys ostrovid [email protected]
    wrote:

    I am currently using persistent-2.1.1.2 and persistent-sqlite-2.1.1.1 in a
    sandbox.

    in my config/models file I have a section, where I define a datatype
    storing a timestamp in UTCTime

    Medium
    title Text
    path FP.FilePath
    thumb FP.FilePath
    mime Text
    time UTCTime
    owner UserId
    description Textarea
    tags Texts
    album AlbumId
    deriving Eq Show

    One line of code that prodces the is fore example in Handler/Home.hs of
    my aforementioned project, where I access all media and sort them by
    timestamp:

    recentMedia <- runDB $ selectList [] [Desc MediumTime]

    When accessing a single medium with

    tempMedium <- runDB $ get mediumId

    the server will throw a similar error:

    get MediumKey {unMediumKey = SqlBackendKey {unSqlBackendKey = 1}}: field time: Expected UTCTime, received PersistText "2014-12-23T04:01:11.786518"

    I hope this clarifies the problem I encounter.

    —
    Reply to this email directly or view it on GitHub
    #339 (comment).

  4. nek0 commented on Dec 23, 2014

    @nek0
    Author

    unfortunately yes.

  5. snoyberg commented on Dec 23, 2014

    @snoyberg
    Member

    This is a regression caused by the fix for #328. Should be an easy fix, just a few minutes...

  6. snoyberg commented on Dec 23, 2014

    @snoyberg
    Member

    I've just pushed a commit which tweaks the persistent package to fix it. I'm going through release procedures now, but you can install from the repo directly to give it a shot. (Note: the fix is in persistent, not persistent-sqlite.)

  7. nek0 commented on Dec 23, 2014

    @nek0
    Author

    Thank you very much, that fixed the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions