Skip to content

Inspecting bound placeholder values #645

Description

@mirosval

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions