yesodweb / yesodweb/persistent

Different encoding behavior for PersistDbSpecific with persistent-postgresql and persistent-mysql

Open
#1,110 1 comment 1 reaction 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

What is the discrepancy?

persistent-mysql and persistent-postgresql encode PersistDbSpecific differently.

persistent-mysql uses Plain:

https://github.com/yesodweb/persistent/blob/31e25c41c648fbbf5cca7cb79665482d008931bf/persistent-mysql/Database/Persist/MySQL.hs#L239

However, persistent-postgresql uses Escape (effectively, treating it as a string-like value):

https://github.com/yesodweb/persistent/blob/31e25c41c648fbbf5cca7cb79665482d008931bf/persistent-postgresql/Database/Persist/Postgresql.hs#L554

When was this introduced?

The behavior for PostgreSQL changed with 9287943c1dd4ca0c9822a715c057f4fb2ab6888e.

Why is this a problem?

With the current behavior it is not possible to encode something like point '(2.0,0)' for PostgreSQL.

(I would also be very surprised if the example given in the docs for PersistDbSpecific is still anywhere close working; but I haven't tried that specifically.)

How to address this?

I'm not sure how to best address this. Altering how PersistDbSpecific is encoded would be a breaking change that isn't detected by the type checker. One solution might be to remove PersistDbSpecific and add two new constructors:

  • PersistDbSpecificEscape, which uses Escape (current behavior of persistent-postgresql)
  • PersistDbSpecificPlain, which uses Plain (current behavior of persistent-mysql)

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

Compare the PersistDbSpecific handling in persistent-mysql/Database/Persist/MySQL.hs and persistent-postgresql/Database/Persist/Postgresql.hs, including the referenced PostgreSQL change 9287943c1dd4ca0c9822a715c057f4fb2ab6888e. First establish the intended distinction between Plain and Escape, then determine an agreed backward-compatible API and verify that the documented PostgreSQL example works with the resulting behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
databases
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.