yesodweb / yesodweb/persistent

incorrect casing of false in `someField default=false` silently causes migrations to always happen

Open
#1,171 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Haskell
Stars
486
Forks
306
PR merge metrics
No merged PRs in 30d

Description

We had a splice in production like:

Persist.share [Persist.mkPersist Persist.sqlSettings, Persist.mkMigrate "migrateAll"] [Persist.persistLowerCase|
Person
    isAwake Bool default=False
|]

When it came time to migrate, persistent would apply it. The next reload though, persistent would apply it again and then every run after.

If you lowercase False to false then the correct behavior happens: migration only happens once until something changes.

Postgres seems to not care about the casing here, but the check for if a migration is necessary does.

I think the correct behavior would be for either the quasiquoter to fail here for default=False or for the migration check to be case insensitive.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Persistent migration with the shown isAwake Bool default=False schema and compare it with lowercase default=false. Trace the quasiquoter and migration-checking paths to determine where casing diverges. Done means the invalid casing is rejected or equivalent casing no longer causes the migration to run repeatedly.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.