Scala 22param restriction tries to find a workaround and still use for understanding instead of plain SQL in Slick

I work with 23 fields here, after all. I usually raised my hands up, trying to count them after cutting from a table with 31 fields using a foreign key.

All good links

A fundamental explanation of how to read and understand the Slick schema code provided by one very good Fise.

By 22 + parameters ...

Stefan Zeigar was extremely helpful in the sample code he wrote in this discussion , and is also more directly related to here on Github

Good Stefan Zeigar also posted here for simple SQL queries.

What is this message about

I think the above is enough to get me to go into working refactoring my application so that CRUD is feasible. I will update this question or ask new questions if something comes and stalls me. The fact is that...

I skip using to understand requests. I am talking about Slick Query Templates

The problem that I encounter when I use for understanding is that the table ... probably has

object Monsters extends Table[Int]("monster_table"){ // lots of column definitions def * = id /* for a Table[Int] despite having 21 other columns I'm not describing in this projection/ColumnBase/??? */ } 

and the projection * will not describe everything that I want to return in the request.

A typical Slick template that is easy to understand will look something like this:

 def someQueryTemplate = for { m <- Monsters } yield m 

and m will be Int instead of the whole object that I want, because I declared that the table is Table[Int] , because I can’t build the projection from 22 parameters because of all the code that needs to be generated to support the class generation compiler for each tuple and arbitrariness

So ... in a nutshell:


Can I use Query Templates in Slick with 22+ columns?

+7
sql database scala tuples slick
source share
1 answer

I came across this question by answering a similar question a couple of days ago. Here is the link to the question. slick error: type TupleXX is not included in the scala package (XX> 22)

To answer this question, you can use nested tuples to solve the 22-column limit. When I solved the problem myself, the following article was extremely helpful. https://groups.google.com/forum/#!msg/scalaquery/qjNW8P7VQJ8/ntqCkz0S4WIJ

Another option is to use the version of Slick that will be released soon, which uses HLists to remove the column limit. This version of Slick can be pulled from the Slick Wizard branch on Github. Kudos to indicating this option. https://github.com/slick/slick/blob/master/slick-testkit/src/main/scala/com/typesafe/slick/testkit/tests/MapperTest.scala#L249

+2
source share

All Articles