yesodweb / yesodweb/persistent

connectionString support in `FromJSON` for `PostgresConf`

Open
#901 9 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

Would the maintainers be open to a PR expanding the FromJSON implementation for PostgresConf so that it accepts a connectionString value as an alternative to passing database, host, port, user, and password individually?

I generated a new Yesod application using stack new foo yesodweb/postgres, and the first thing I wanted to do was get the generated code up and running on Heroku. Heroku provides the postgres connection string as a single environment variable in a libpq-compatible format, so it would be convenient to be able to pass that same value straight through to the configuration. Since the template-generated starter code from stack new uses the FromJSON implementation for PostgresConf as the basis for configuration with environment variables, it seems like expanding the FromJSON implementation would be a sensible way to add connectionString support.

I worked around this with newtype to get something working in my own app. I'd be happy to submit a PR with the FromJSON changes.

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 locating the FromJSON implementation for PostgresConf and the template-generated configuration path described in the issue. Compare its existing field parsing with the requested connectionString input, then add coverage showing that a libpq-compatible value is accepted while existing individual fields continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, postgresql
Domain
databases
Issue type
Feature
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.