Slick: Combining SQL and Query API

I have complex SQL that returns two columns after execution Long. Now, how can I write queries, for example the following:

val sqlStr: String = ??? // My complex SELECT statment
val sqlQuery = queryNA[(Long, Long)](sqlStr)
for {
  data <- tableQuery if data.id in sqlQuery._1
} yield data

I expect it to produce something like SELECT ... FROM table WHERE table.id IN (SELECT ...) Is this possible? And if not, can you indicate some other way or workaround to do something like this? The problems are here:

  • Most of the other parts use the request API, and I want it to be interoperable.
  • Executing sqlStrdirectly will lead to many results, and I would like to avoid this.
+4
source share
1 answer

(Query API) SQL . , scala, . SQL-. , - , .

, - : https://github.com/slick/slick/issues/756

+2

Source: https://habr.com/ru/post/1535598/


All Articles