@@ -168,6 +168,37 @@ class ReadSuite extends munit.FunSuite with ReadSuitePlatform {
168
168
assertEquals(o2, List (None ))
169
169
}
170
170
171
+ test(" Read should read correct columns for instances with Option (None) with left join between two tables" ) {
172
+ import doobie .implicits .*
173
+
174
+ case class Foo (foo_key : Int , b : String )
175
+ case class Bar (bar_key : Int , d : Option [String ])
176
+
177
+ val result : List [(Foo , Option [Bar ])] = (for {
178
+ _ <- sql " drop table if exists foo " .update.run
179
+ _ <- sql " drop table if exists bar " .update.run
180
+ _ <- sql " create table foo(foo_key int, foo_value varchar not null) " .update.run
181
+ _ <- sql " create table bar(bar_key int, foo_key int, bar_value varchar) " .update.run
182
+
183
+ _ <- sql " insert into foo values (1, 'a'), (2, 'b'), (3, 'c') " .update.run
184
+ _ <- sql " insert into bar values (1, 1, 'c'), (2, 2, null) " .update.run
185
+
186
+ q <-
187
+ sql " select f.foo_key, f.foo_value, b.bar_key, b.bar_value from foo f left join bar b on f.foo_key = b.foo_key "
188
+ .query[(Foo , Option [Bar ])].to[List ]
189
+ } yield q)
190
+ .transact(xa)
191
+ .unsafeRunSync()
192
+
193
+ assertEquals(
194
+ result,
195
+ List (
196
+ (Foo (1 , " a" ), Some (Bar (1 , Some (" c" )))),
197
+ (Foo (2 , " b" ), Some (Bar (2 , None ))),
198
+ (Foo (3 , " c" ), None )
199
+ ))
200
+ }
201
+
171
202
test(" Read should read correct columns for instances with Option (Some)" ) {
172
203
import doobie .implicits .*
173
204
0 commit comments