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

PersistMarshalError with UTCTime on Sqlite #339

Closed
nek0 opened this Issue Dec 23, 2014 · 7 comments

Comments

Projects
None yet
2 participants
@nek0

nek0 commented Dec 23, 2014

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?

@snoyberg

This comment has been minimized.

Show comment
Hide comment
@snoyberg

snoyberg Dec 23, 2014

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.

Member

snoyberg commented Dec 23, 2014

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.

@nek0

This comment has been minimized.

Show comment
Hide comment
@nek0

nek0 Dec 23, 2014

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.

nek0 commented Dec 23, 2014

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.

@snoyberg

This comment has been minimized.

Show comment
Hide comment
@snoyberg

snoyberg Dec 23, 2014

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 notifications@github.com
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).

Member

snoyberg commented Dec 23, 2014

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 notifications@github.com
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).

@nek0

This comment has been minimized.

Show comment
Hide comment
@nek0

nek0 Dec 23, 2014

unfortunately yes.

nek0 commented Dec 23, 2014

unfortunately yes.

@snoyberg

This comment has been minimized.

Show comment
Hide comment
@snoyberg

snoyberg Dec 23, 2014

Member

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

Member

snoyberg commented Dec 23, 2014

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

snoyberg added a commit that referenced this issue Dec 23, 2014

@snoyberg

This comment has been minimized.

Show comment
Hide comment
@snoyberg

snoyberg Dec 23, 2014

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.)

Member

snoyberg commented Dec 23, 2014

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.)

@nek0

This comment has been minimized.

Show comment
Hide comment
@nek0

nek0 Dec 23, 2014

Thank you very much, that fixed the problem.

nek0 commented Dec 23, 2014

Thank you very much, that fixed the problem.

@snoyberg snoyberg closed this Dec 23, 2014

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