IN Query Param

29 views
Skip to first unread message

Trevor Austin

unread,
Nov 30, 2009, 9:17:47 PM11/30/09
to Lift
I have some slow code:

val users:List[User] = Tag.findAll(By(Tag.tagType,this), OrderBy
(Tag.created_at, Descending), MaxRows(100), PreCache(Tag.user)).map
(_.user.obj.open_!)

That I turned into faster ugly code:

val users:List[User] = User.findAll(BySql("WHERE id IN (SELECT TOP 100
user from Tag where tagType = ? ORDER BY created_at DESC )",
IHaveValidatedThisSQL("trevoraustin","2009-11-30"), this.id))

That I want to turn into faster nicer code:

val users:List[User] = User.findAll(In(User.id, Tag.user, By
(Tag.tagType, this), OrderBy(Tag.created_at, Descending), MaxRows
(100)))

But I get the error:

"no implicit argument matching parameter type (Product with
net.liftweb.mapper.QueryParam[_ <: com.udorse.lift.model.Tag]) =>
net.liftweb.mapper.QueryParam[com.udorse.lift.model.Tag] was found."

If I try just:

val users:List[User] = User.findAll(In(User.id, Tag.user, By
(Tag.tagType, this), OrderBy(Tag.created_at, Descending)))

Without the MaxRows it compiles fine. Is there a limit on the
QueryParams I can use with In? Am I doing something else wrong?

Trevor Austin

unread,
Nov 30, 2009, 9:25:10 PM11/30/09
to Lift
Never mind, it just needed a type hint:

val users:List[User] = User.findAll(In(User.id, Tag.user, By
(Tag.tagType, this), OrderBy(Tag.created_at, Descending), MaxRows[Tag]
(100)))

David Pollak

unread,
Nov 30, 2009, 10:15:24 PM11/30/09
to lif...@googlegroups.com
On Mon, Nov 30, 2009 at 6:25 PM, Trevor Austin <trau...@gmail.com> wrote:
Never mind, it just needed a type hint:

Sometimes the type inferencer gets it right and sometimes it needs some extra help.
 
--

You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.





--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics
Reply all
Reply to author
Forward
0 new messages