【发布时间】:2013-05-22 19:46:02
【问题描述】:
找到匹配用户名的用户的正确方法是什么?
使用用户自定义类型用户:
case class User (userId: String, username: String)
object User extends Table[User]("user") {
def userId = column[String]("userId", O.PrimaryKey)
def username = column[String]("username")
def * = userId ~ authId ~ username <>(User.apply _, User.unapply _)
Database.forDataSource(DB.getDataSource()) withSession {
implicit session: Session =>
val q = for { u <- User if u.username.equalsIgnoreCase(someUsername) }
yield u
q.headOption
user.username 是 Column[String] 类型,没有转换为 String。
希望数据库在查询中进行字符串不敏感比较。
【问题讨论】: