2014-04-05 1 views
1

이제 Slick의 compiled queries 기능을 사용하려고합니다. 간단한 쿼리의 경우 제대로 작동하지만 Tuple 반환 형식의 조인과 관련된 쿼리는 컴파일 오류를 발생시킵니다. 나는 다음과 같은 컴파일 오류가 발생하는Slick 2가 튜플을 반환하는 쿼리를 컴파일하지 못합니다.

val byArticleCompiled = Compiled((id: Column[Int]) => comments 
    .filter(_.articleId === id) 
    .leftJoin(users).on(_.userId === _.id) 
) 

def getByArticle(id: Int)(implicit session: JdbcBackend#Session) = byArticleCompiled(id).list 

처럼 수정하기 위해 노력하고있어 때

def getByArticle(id: Int)(implicit session: JdbcBackend#Session) = { 
     comments 
     .filter(_.articleId === id) 
     .leftJoin(users).on(_.userId === _.id) 
     .list 
    } 

:

는 여기에 내가 컴파일 된 쿼리 재 작성하기 위해 노력하고있어 DAO 방법 중 하나입니다 :

[오류] 유형 계산 의견 RepepitoryC omponentImpl.this.profile.simple.Column [지능] => scala.slick.lifted.WrappingQuery [(CommentsRepositoryComponentImpl.this.Comments, CommentsRepositoryComponentImpl.this.Users) (# 1 CommentsRepositoryComponentImpl.this.Comments TableElementType, CommentsRepositoryComponentImpl. this.Users #의 TableElementType]를 컴파일 할 수 없습니다 수)() 타입 C로 [오류] 발 byArticleCompiled = 컴파일 ((ID : 열 [지능]) =이> 그 또는 뒤에 어떤 개념적인 문제가

코멘트 나는 somehting을 잘못하고 있냐?

답변

1

조인에 의해 생성 된 쿼리에 대해 Executable typeclass에 문제가있는 것 같습니다. 해결 방법으로 .withFilter(_ => true)과 같은 더미 연산을 추가하면 컴파일됩니다. 2.0.2 (https://github.com/slick/slick/issues/746)에 대해 살펴볼 것입니다.

+0

감사합니다. 조인 후에 정렬 (어쨌든 필요함)을 배치하고 이제는 작동합니다. – Jk1

관련 문제