@@ -53,6 +53,37 @@ class MySQLSampleSpec extends FlatSpec with Matchers with DBSettings with Loggin
5353 results.size should equal(2 )
5454 }
5555
56+ it should " read values with convenience methods" in {
57+ val generatedIdFuture : Future [Long ] = AsyncDB .withPool { implicit s =>
58+ withSQL {
59+ insert.into(AsyncLover ).namedValues(
60+ column.name -> " Eric" ,
61+ column.rating -> 2 ,
62+ column.isReactive -> false ,
63+ column.createdAt -> createdTime).returningId
64+ }.updateAndReturnGeneratedKey.future()
65+ }
66+ // in AsyncLover#apply we are using get with typebinders, specialized getters should work
67+ val generatedId = Await .result(generatedIdFuture, 5 .seconds)
68+ val created = DB .readOnly { implicit s =>
69+ withSQL { select.from(AsyncLover as al ).where.eq(al.id, generatedId) }.map((rs : WrappedResultSet ) => {
70+ AsyncLover (
71+ id = rs.long(al.resultName.id),
72+ name = rs.stringOpt(al.resultName.name).get,
73+ rating = rs.int(al.resultName.rating),
74+ isReactive = rs.boolean(al.resultName.isReactive),
75+ lunchtime = rs.timeOpt(al.resultName.lunchtime),
76+ birthday = rs.jodaDateTimeOpt(al.resultName.lunchtime),
77+ createdAt = rs.jodaDateTime(al.resultName.createdAt))
78+ }).single.apply()
79+ }.get
80+ created.id should equal(generatedId)
81+ created.name should equal(" Eric" )
82+ created.rating should equal(2 )
83+ created.isReactive should be(false )
84+ created.createdAt should equal(createdTime)
85+ }
86+
5687 it should " return generated key" in {
5788 val generatedIdFuture : Future [Long ] = NamedAsyncDB (' mysql ).withPool { implicit s =>
5889 withSQL {
0 commit comments