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.
我在这里有23个字段。我通常会在使用外键从31个字段的表中减少之后,尝试数一数。
All the good links
Fundamental explanation of how to read and understand Slick's schema code provided by one very good Faiz.
关于如何阅读和理解一个非常好的Faiz提供的图式代码的基本解释。
On 22+ parameters...
22日+参数…
Stefan Zeigar has been immensely helpful in the example code he's written in this discussion and also more directly linked to here on Github
Stefan Zeigar在本讨论中编写的示例代码中提供了极大的帮助,并且更直接地链接到了Github上
The good Stefan Zeigar has also posted here on plain SQL queries
优秀的Stefan Zeigar也在这里发布了纯SQL查询
What this post is about
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...
我认为,上面的内容足以让我开始对我的应用程序进行重构,从而使CRUD成为可行的。如果有什么事情让我停滞不前,我会更新这个问题或者问新的问题。事情是这样的……
I miss using for comprehensions for querying. I'm talking about Slick's Query Templates
我怀念使用for tion for querying。我说的是Slick的查询模板
The problem I run into when I use a for comprehensions is that the table... will probably have
当我使用a进行理解时,我遇到的问题是表格……可能会
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 won't describe everything I want to return in a query.
而*投影不会描述我想要在查询中返回的所有东西。
The usual simple for comprehension Slick query template will look something like this:
常见的简单的理解平滑的查询模板看起来是这样的:
def someQueryTemplate = for {
m <- Monsters
} yield m
and m
will be an Int instead of the entire object I want because I declared the table to be a Table[Int]
because I can't construct a mapped projection of 22 params because of all the code that needs to be generated for compiler support of class generation for each tuple and arbitrariness
和m将Int,而不是整个对象我想因为我宣布表一个表(Int)因为我不能构建一个映射的投影22 params因为需要为编译器生成的代码支持每个元组的类生成和任意性
So... in a nutshell:
所以…简而言之:
Is there any way to use Query Templates in Slick with 22+ columns?
1 个解决方案
#1
2
I stumbled on this question after answering a similar question a couple days ago. Here's a link to the question. slick error : type TupleXX is not a member of package scala (XX > 22)
我在几天前回答了一个类似的问题后偶然发现了这个问题。这是问题的链接。圆滑错误:类型TupleXX不是包scala的成员(XX > 22)
To answer the question here, you are able to use nested tuples to solve the 22 column limit. When solving the problem myself, the following post was extremely helpful. https://groups.google.com/forum/#!msg/scalaquery/qjNW8P7VQJ8/ntqCkz0S4WIJ
要回答这个问题,您可以使用嵌套元组来解决22列的限制。当我自己解决这个问题时,下面的帖子非常有用。https://groups.google.com/forum/ !味精/ scalaquery / qjNW8P7VQJ8 / ntqCkz0S4WIJ
Another option is to use the soon-to-be-released version of Slick which uses HLists to remove the column count limitation. This version of Slick can be pulled from the Slick master branch on Github. Kudos to cvogt for pointing out this option. https://github.com/slick/slick/blob/master/slick-testkit/src/main/scala/com/typesafe/slick/testkit/tests/MapperTest.scala#L249
另一个选择是使用即将发布的光滑版本,它使用hlist来删除列计数限制。这个版本的浮油可以从Github上的浮油大师分支中提取出来。感谢cvogt指出这个选项。https://github.com/slick/slick/blob/master/slick-testkit/src/main/scala/com/typesafe/slick/testkit/tests/MapperTest.scala L249
#1
2
I stumbled on this question after answering a similar question a couple days ago. Here's a link to the question. slick error : type TupleXX is not a member of package scala (XX > 22)
我在几天前回答了一个类似的问题后偶然发现了这个问题。这是问题的链接。圆滑错误:类型TupleXX不是包scala的成员(XX > 22)
To answer the question here, you are able to use nested tuples to solve the 22 column limit. When solving the problem myself, the following post was extremely helpful. https://groups.google.com/forum/#!msg/scalaquery/qjNW8P7VQJ8/ntqCkz0S4WIJ
要回答这个问题,您可以使用嵌套元组来解决22列的限制。当我自己解决这个问题时,下面的帖子非常有用。https://groups.google.com/forum/ !味精/ scalaquery / qjNW8P7VQJ8 / ntqCkz0S4WIJ
Another option is to use the soon-to-be-released version of Slick which uses HLists to remove the column count limitation. This version of Slick can be pulled from the Slick master branch on Github. Kudos to cvogt for pointing out this option. https://github.com/slick/slick/blob/master/slick-testkit/src/main/scala/com/typesafe/slick/testkit/tests/MapperTest.scala#L249
另一个选择是使用即将发布的光滑版本,它使用hlist来删除列计数限制。这个版本的浮油可以从Github上的浮油大师分支中提取出来。感谢cvogt指出这个选项。https://github.com/slick/slick/blob/master/slick-testkit/src/main/scala/com/typesafe/slick/testkit/tests/MapperTest.scala L249