From d9d344ac0a33fe46cc6866d5c9403f466904b461 Mon Sep 17 00:00:00 2001 From: Joe Zulli Date: Sun, 26 Mar 2023 22:06:16 -0700 Subject: [PATCH 1/2] Add example of querying with a WHERE IN clause --- modules/docs/src/main/paradox/reference/Encoders.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/docs/src/main/paradox/reference/Encoders.md b/modules/docs/src/main/paradox/reference/Encoders.md index 5a6dcae7..9e727a0d 100644 --- a/modules/docs/src/main/paradox/reference/Encoders.md +++ b/modules/docs/src/main/paradox/reference/Encoders.md @@ -78,6 +78,17 @@ val enc = (varchar ~ int4).values sql"INSERT INTO person (name, age) VALUES ${enc.list(3)}" ``` +Similarly, the `values` and `list` combinators can be used to encode an `IN` clause for queries. + +```scala mdoc:nest +case class Person(name: String, age: Int) + +val names = List("Ron", "Leslie", "Andy") +val namesEnc = varchar.values.list(names.length) + +sql"SELCT * FROM person WHERE name IN $namesEnc" +``` + ## Transforming the Input Type An `Encoder[A]` consumes a value of type `A` and encodes it for transmission Postgres, so it can From fa8a6d557f6f8c7a25ea13f7c224a2a64fac8044 Mon Sep 17 00:00:00 2001 From: Joe Zulli Date: Tue, 28 Mar 2023 22:15:48 -0700 Subject: [PATCH 2/2] Fix typo --- modules/docs/src/main/paradox/reference/Encoders.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/docs/src/main/paradox/reference/Encoders.md b/modules/docs/src/main/paradox/reference/Encoders.md index 9e727a0d..25b084a2 100644 --- a/modules/docs/src/main/paradox/reference/Encoders.md +++ b/modules/docs/src/main/paradox/reference/Encoders.md @@ -86,7 +86,7 @@ case class Person(name: String, age: Int) val names = List("Ron", "Leslie", "Andy") val namesEnc = varchar.values.list(names.length) -sql"SELCT * FROM person WHERE name IN $namesEnc" +sql"SELECT * FROM person WHERE name IN $namesEnc" ``` ## Transforming the Input Type