Inspecting bound placeholder values
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 2.2k
- Forks
- 379
- Avg merge
- 14m
- Merged PRs (30d)
- 8
Description
Hi and thank you for this amazing library!
In my application I have built a layer that takes some parameters (like order by, offset, limit) and builds out a Fragment with the full SQL query from them. A lightweight SQL DSL if you will.
My problem is with writing tests for this - I can test something like this:
req.whereColumnFragment.toString shouldBe Fragment.const("column = ?").toString
but, I can not test that the placeholder has been properly passed in. I would like to do something like:
val abc = "abc"
val correct = fr"column = $abc"
req.whereColumnFragment.placeholders.head shouldBe correct.placeholders.head
Here placeholders is essentially equivalent to the protected def a: A on the
Fragment sealed trait.
Problem is that it is protected so I can only access it from tests using reflection.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with modules/core/src/main/scala/doobie/util/fragment.scala, especially the Fragment sealed trait and its protected def a. Review how the issue's tests currently use reflection to inspect placeholders, then determine an accessible inspection API that preserves the existing Fragment abstraction. Done means callers can compare bound placeholder values without reflection and the relevant tests cover that behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala, sql
- Domain
- database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100