I want select the max value using this query (all fields in table are not null):
dc.run(quote {
query[SchemaInfo]
.filter(_.subjectName == lift(subject))
.map(_.version)
.max
}).map(_.map(_ + 1).getOrElse(1))
I know, that table may be empty, so i use this: map(_.map(_ + 1).getOrElse(1))
.
The problem is that this query produces this error:
SQL
NULL
read at column 1 (JDBC type null) but mapping is to a non-Option type; use Option here. Note that JDBC column indexing is 1-based. doobie.util.invariant$NonNullableColumnRead: SQLNULL
read at column 1 (JDBC type null) but mapping is to a non-Option type; use Option here. Note that JDBC column indexing is 1-based.
How to fix it? Without quill (using pure doobie) the same query working correctly