yesodweb / yesodweb/persistent

Question marks inside of strings cause RawSQL to be sad

Open
#1,371 0 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

Suppose you're in a dark room and you're not sure who you're interacting with

[sqlQQ| SELECT 'hello world?' |]

This gives a FormatError because we're trying to split on the ?, even though the ? is not a parameter to substitute syntactically, but a character in the string.

We can work around this by providing the value as a query parameter:

[sqlQQ| SELECT #{PersistText "hello world?"} |]

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 issue with the shown sqlQQ example containing SELECT 'hello world?', then trace the SQL quasiquoter's parameter-splitting logic. Done means question marks inside quoted strings no longer cause a FormatError while substitution still works for actual parameters.

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.