Note that there are some explanatory texts on larger screens.

plurals
  1. POScala 22param limit trying to find a workaround and still use for comprehensions instead of plain SQL in Slick
    text
    copied!<p>I'm working with 23 fields here, at last count. I've generally thrown my hands up with trying to count them after reducing from a 31-fielded table by using a foreign-key.</p> <h1>All the good links</h1> <p><a href="https://stackoverflow.com/a/13909321/1708136">Fundamental explanation of how to read and understand Slick's schema code</a> provided by one very good Faiz.</p> <p><strong>On 22+ parameters...</strong></p> <p>Stefan Zeigar has been immensely helpful in the example code he's written in <a href="https://groups.google.com/forum/#!topic/scalaquery/qjNW8P7VQJ8/" rel="nofollow noreferrer">this discussion</a> and also more directly linked to <a href="https://github.com/slick/slick/commit/7f8668e49da34cf0cb52ac21a6f5b46d0b0fdb47" rel="nofollow noreferrer">here on Github</a></p> <p>The good Stefan Zeigar has also posted <a href="https://groups.google.com/forum/#!topic/scalaquery/qmg5Lj3io9Y/discussion" rel="nofollow noreferrer">here</a> on plain SQL queries</p> <h1>What this post is about</h1> <p>I think the above is enough to get me on my way to a working refactoring of my app so that CRUD is feasible. I'll update this question or ask new questions if something comes up and stagnates me. The thing is...</p> <p>I miss using for comprehensions for querying. I'm talking about <a href="http://slick.typesafe.com/doc/1.0.1/lifted-embedding.html#query-templates" rel="nofollow noreferrer">Slick's Query Templates</a></p> <p>The problem I run into when I use a for comprehensions is that the table... will probably have</p> <pre><code>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/??? */ } </code></pre> <p>and the <code>*</code> projection won't describe everything I want to return in a query. </p> <p>The usual simple for comprehension Slick query template will look something like this:</p> <pre><code>def someQueryTemplate = for { m &lt;- Monsters } yield m </code></pre> <p>and <code>m</code> will be an Int instead of the entire object I want because I declared the table to be a <code>Table[Int]</code> <em>because</em> I can't construct a mapped projection of 22 params because of <a href="https://stackoverflow.com/questions/4152223/why-are-scala-functions-limited-to-22-parameters">all the code that needs to be generated for compiler support of class generation for each tuple and arbitrariness</a></p> <p>So... <em>in a nutshell:</em> <br><br><br></p> <h1>Is there any way to use Query Templates in Slick with 22+ columns?</h1>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload