yesodweb / yesodweb/persistent

Filter `FieldName <-. [Nothing]` not finding expected results

Open
#1,473 6 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

I'm running into some odd behaviour where the filter FieldName <-. [Just v, Nothing] finds rows where FieldName is either null or v, but FieldName <-. [Nothing] doesn't find any rows at all.

  _johnId <- insert $ Person "John Doe" $ Just 35
  _janeId <- insert $ Person "Jane Doe" Nothing

  selectList [] [] -- finds no one
  selectList [PersonAge <-. [Nothing, Just 35]] [] -- finds John and Jane
  selectList [PersonAge <-. [Just 35]] [] -- finds John
  selectList [PersonAge <-. [Nothing]] [] -- expected to find Jane, but finds no one

Here's a complete repro using sqlite, but I've also observed this in Postgres.

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 running the complete sqlite reproduction linked in the issue and compare its results with the listed selectList examples. Trace how Persistent builds filters containing Nothing, then check whether the same behavior can be reproduced with Postgres; done means selectList [PersonAge <-. [Nothing]] returns Jane without breaking the Just cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, postgresql, sqlite
Domain
database
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.