Skip to content

Instantly share code, notes, and snippets.

@jonifreeman
Created January 17, 2011 18:57
Show Gist options
  • Save jonifreeman/783266 to your computer and use it in GitHub Desktop.
Save jonifreeman/783266 to your computer and use it in GitHub Desktop.
case class Book(title: String, date: Date, author: String)
val someDate = new Date
/* Would be nice to return String, PreparedStmt or something instead of Dynamic
val books: Dynamic[String] = Book
val q1 = books.findByTitle("The Stand")
val q2 = books.findByTitleLike("Harry Pot%")
val q3 = books.findByDateGreaterThan(someDate)
*/
// This works but explicit call to typed is verbose
val books: Dynamic = Book
val q1 = books.findByTitle("The Stand").typed[String]
val q2 = books.findByTitleLike("Harry Pot%").typed[String]
val q3 = books.findByDateGreaterThan(someDate).typed[String]
assert(q1 == "select title,date,author from book where title='The Stand'")
assert(q2 == "select title,date,author from book where title like 'Harry Pot%'")
assert(q3 == "select title,date,author from book where date > '" + someDate + "'")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment