Skip to content
#

jdbc

Here are 3,006 public repositories matching this topic...

deusaquilus
deusaquilus commented Oct 26, 2021

The .forall pattern is a great way to create an optional filter for a field that could be defined or not:

case class Person(name: String, age: Int)
val nameOpt: Option[String] = Some("Joe")
run { query[Person].filter(p => lift(nameOpt).forall(_ == p.name)) }
// SELECT p.name, p.age FROM Person p WHERE ? IS NULL OR ? = p.name
// (i.e. when nameOpt := None then the `WHERE ? IS NULL`
yaooqinn
yaooqinn commented Mar 8, 2022

Code of Conduct

Search before asking

  • I have searched in the issues and found no similar issues.

What would you like to be improved?

shell script style consistency

How should we improve?

Maybe

help wanted good first issue kind:infra module:misc

Improve this page

Add a description, image, and links to the jdbc topic page so that developers can more easily learn about it.

Curate this topic

Add this topic to your repo

To associate your repository with the jdbc topic, visit your repo's landing page and select "manage topics."

Learn more