typelevel / typelevel/skunk

Make session (pool) use a specified schema

Open
#376 1 comment 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
1.7k
Forks
175
Avg merge
5d 14h
Merged PRs (30d)
9

Description

The goal is to have queries/commands target a specified schema instead of the default "public"

As @tpolecat suggested this is achieved by setting the search_path session connection parameter.

And indeed it works. This is a battle tested example:

    import skunk._
    implicit val noopTrace: Trace[F] = Trace.Implicits.noop[F]
    
    Session.pooled(
        parameters = Map("search_path", "my_schema") ++ Session.DefaultConnectionParameters,
        host       = ???,
        port       = ???,
        user       = ???,
        database   = ???,
        password   = ???
      )

Furthermore, by looking at the postgresql docs the search_path is a a complex beast, and there's many more ways to use it.

So it's up for disscussion what the best API would be to easily allow doing the above with minimal footgunning risk.

At the very least this issue helps people find the way to solve the same problem.

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 with the Session.pooled entry point and its parameters, including Session.DefaultConnectionParameters. Read the PostgreSQL search_path documentation and compare the existing parameter approach with the API options discussed in the issue. Done means there is a decided, safe API for targeting a specified schema without unnecessary footguns.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgres, scala
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.