Skip to content

Fix missing UTC timezone "Z" in Sqlite UTCTime strings#1585

Merged
parsonsmatt merged 4 commits intoyesodweb:masterfrom
malteneuss:fix_sqlite_utctime_text
May 15, 2025
Merged

Fix missing UTC timezone "Z" in Sqlite UTCTime strings#1585
parsonsmatt merged 4 commits intoyesodweb:masterfrom
malteneuss:fix_sqlite_utctime_text

Conversation

@malteneuss
Copy link
Contributor

@malteneuss malteneuss commented Apr 13, 2025

I noticed that the Sqlite formatting from UTCTime values to string (sqlite doesn't support datetime natively) is missing the UTC timezone marker "Z". So it should be e.g. "2025-04-12T06:53:42Z" instead of "2025-04-12T06:53:42".

I made this change is non-breaking (UTC timezone was implicitly assumed before) by keeping the old parsing logic so new and old format can be read from existing databases.

Loosely related to #1542 #1117 and #339

Before submitting your PR, check that you've:

  • Documented new APIs with Haddock markup
  • Added @since declarations to the Haddock
  • Ran fourmolu on any changed files (restyled will do this for you, so
    accept the suggested changes if it makes them)
  • Adhered to the code style (see the .editorconfig and fourmolu.yaml files for details)

After submitting your PR:

  • Update the Changelog.md file with a link to your PR
  • Bumped the version number if there isn't an (unreleased) on the Changelog
  • Check that CI passes (or if it fails, for reasons unrelated to your change, like CI timeouts)

@malteneuss malteneuss force-pushed the fix_sqlite_utctime_text branch from 26f3a8a to 97e1bb7 Compare April 13, 2025 21:02
@malteneuss malteneuss changed the title WIP: Fix missing timezone in Sqlite UTCTime string WIP: Fix missing UTC timezone "Z" in Sqlite UTCTime string Apr 13, 2025
@malteneuss malteneuss changed the title WIP: Fix missing UTC timezone "Z" in Sqlite UTCTime string WIP: Fix missing UTC timezone "Z" in Sqlite UTCTime strings Apr 13, 2025
@malteneuss malteneuss force-pushed the fix_sqlite_utctime_text branch from 97e1bb7 to 2d08c82 Compare April 13, 2025 21:05
@malteneuss malteneuss changed the title WIP: Fix missing UTC timezone "Z" in Sqlite UTCTime strings Fix missing UTC timezone "Z" in Sqlite UTCTime strings Apr 13, 2025
@malteneuss malteneuss force-pushed the fix_sqlite_utctime_text branch 2 times, most recently from 80a4a74 to 7ac704f Compare April 14, 2025 12:11
@malteneuss
Copy link
Contributor Author

malteneuss commented Apr 14, 2025

I can't format PersistField.hs due to (using fourmolu from nix develop):

$ fourmolu -i persistent/Database/Persist/Class/PersistField.hs
persistent/Database/Persist/Class/PersistField.hs:345:5-20
  The GHC parser (in Haddock mode) failed:
  [GHC-58481] parse error on input `fromPersistValue'

Maybe someone can tell me what's wrong from the logs? I can't read what restyled wrote due to permissions...

@malteneuss malteneuss force-pushed the fix_sqlite_utctime_text branch 2 times, most recently from 16d110a to b4430b0 Compare April 14, 2025 12:38
Copy link
Collaborator

@parsonsmatt parsonsmatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks great, thanks for putting this together!

Don't worry about the restyled. That's complaining about the CPP for some reason.

I have a question/concern on backwards/forwards compatibility with persistent-sqlite and the new formatting. We may be breaking downstream users if the timestamp formatting changes in versions, so we may need to be a little more careful about how we do this.

@parsonsmatt
Copy link
Collaborator

If you want to fix the issue with restyled, here's the PR that does it: https://github.com/yesodweb/persistent/pull/1586/files

We'll conflict if I merge first. I'm happy to merge this one in first and fix the conflict later, but each CPP block needs to have a full declaration in it, so that's why it's breaking.

@malteneuss
Copy link
Contributor Author

Since this restyled action touches a more than my changes, i'd like to post pone it.

@malteneuss
Copy link
Contributor Author

I will squash and rebase before the final merge

@malteneuss malteneuss force-pushed the fix_sqlite_utctime_text branch from 44fc521 to 3006c07 Compare April 15, 2025 19:23
@malteneuss
Copy link
Contributor Author

malteneuss commented Apr 15, 2025

Squashed

@malteneuss malteneuss requested a review from parsonsmatt April 15, 2025 19:23
Copy link
Collaborator

@parsonsmatt parsonsmatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice, thanks!

@malteneuss
Copy link
Contributor Author

fyi: I don't have merge rights. Anything else i can do? E.g. there seems to be an issue with the GHC 8.8 pipeline, but i can't read the logs. Or is there maybe a waiting period?

@parsonsmatt
Copy link
Collaborator

Logs:
image

@malteneuss
Copy link
Contributor Author

@parsonsmatt should be good now

@malteneuss malteneuss requested a review from parsonsmatt May 7, 2025 13:01
@parsonsmatt
Copy link
Collaborator

Great, thanks! I'll try to get this released today

@parsonsmatt parsonsmatt merged commit b5ba120 into yesodweb:master May 15, 2025
9 of 10 checks passed
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

Successfully merging this pull request may close these issues.

2 participants