Created
October 1, 2013 03:34
-
-
Save kamekoopa/6773533 to your computer and use it in GitHub Desktop.
scalikejdbcでフィールド名の解決に失敗する?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Hoge(id: String) | |
object HogeTable extends SQLSyntaxSupport[Hoge]{ | |
//ry | |
} | |
//これだとh.idのコンパイルが失敗する | |
def doSomething() = { | |
findOther.right.flatMap { result => //Eitherを返すDB処理 | |
val h = HogeTable.syntax("h") | |
withSQL { | |
select | |
.from(HogeTable as h) | |
.where.eq(h.id, "id") | |
} | |
//.map(ry) | |
.single() | |
.apply() | |
.toRight(new Exception("not found")) | |
} | |
} | |
//これだとOK | |
def doSomething() = { | |
val hid = h.id | |
findOther.right.flatMap { result => //Eitherを返すDB処理 | |
val h = HogeTable.syntax("h") | |
withSQL { | |
select | |
.from(HogeTable as h) | |
.where.eq(hid, "id") | |
} | |
//.map(ry) | |
.single() | |
.apply() | |
.toRight(new Exception("not found")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment