Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embed frags in sql interpolator #51

Merged
merged 3 commits into from
Nov 13, 2024
Merged

Embed frags in sql interpolator #51

merged 3 commits into from
Nov 13, 2024

Conversation

AugustNagro
Copy link
Owner

A solution to #34

@EvgenyAfanasev
Copy link
Contributor

What about improving the test by inserting frag in the middle of the query ?

  test("embed Frag into Frag"):
    def findPersonCnt(
        filter: Frag,
        limit: Long = 1,
        offset: Long = 0
    )(using DbCon): Int =
      sql"SELECT count(*) FROM person WHERE $filter LIMIT $limit OFFSET $offset"
        .query[Int]
        .run()
        .head
    val isAdminFrag = sql"is_admin = true"
    connect(ds()):
      val johnCnt = findPersonCnt(sql"first_name = 'John' AND $isAdminFrag", 2)
      assertEquals(johnCnt, 2)

@AugustNagro
Copy link
Owner Author

Good suggestion; please review @EvgenyAfanasev and I will merge when you approve.

@AugustNagro AugustNagro changed the title WIP: Embed frags in sql interpolator Embed frags in sql interpolator Nov 13, 2024
@EvgenyAfanasev
Copy link
Contributor

Good suggestion; please review @EvgenyAfanasev and I will merge when you approve.

Thank you ! LGTM

@AugustNagro AugustNagro merged commit d2c977f into master Nov 13, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants