Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Dynamic sortBy
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Pradeep Kumar Mishra  
View profile  
 More options Nov 14 2012, 4:09 am
From: Pradeep Kumar Mishra <pkmis...@gmail.com>
Date: Wed, 14 Nov 2012 01:09:30 -0800 (PST)
Local: Wed, Nov 14 2012 4:09 am
Subject: Dynamic sortBy

This is with reference to thread
- https://groups.google.com/forum/#!searchin/scalaquery/sort/scalaquery...

What's the current best way to go for dynamic sorting. I am using following
query

val q2 = q1.sortBy[scala.slick.lifted.Column[Option[String]]](queryParams.sortTerm
match {
      case "itemSKU" =>   _._2
      case "price" =>  _._3
      case _ =>   _._1
    })

But since I need to specify type (in red) the returning column type can not
be dynamic. Looks like I am doing something wrong here.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pradeep Kumar Mishra  
View profile  
 More options Nov 14 2012, 4:13 am
From: Pradeep Kumar Mishra <pkmis...@gmail.com>
Date: Wed, 14 Nov 2012 01:13:12 -0800 (PST)
Local: Wed, Nov 14 2012 4:13 am
Subject: Re: Dynamic sortBy

FYI getting following error if I do not specify any type in sortBy

No implicit view available from scala.slick.lifted.Column[_ >:
Option[String] with Double with String] => scala.slick.lifted.Ordered.

On Wednesday, November 14, 2012 4:09:30 AM UTC-5, Pradeep Kumar Mishra
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ryan Bair  
View profile  
 More options Nov 14 2012, 9:06 am
From: Ryan Bair <ryandb...@gmail.com>
Date: Wed, 14 Nov 2012 09:05:50 -0500
Local: Wed, Nov 14 2012 9:05 am
Subject: Re: Dynamic sortBy

Columns have methods desc and asc on them which return an Ordering. Rather
than just returning _._2 from the case you could return _._2.desc instead.
You should not need the type parameter if you do that.

On Wed, Nov 14, 2012 at 4:13 AM, Pradeep Kumar Mishra <pkmis...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pradeep Kumar Mishra  
View profile  
 More options Nov 14 2012, 7:33 pm
From: Pradeep Kumar Mishra <pkmis...@gmail.com>
Date: Wed, 14 Nov 2012 16:33:25 -0800 (PST)
Local: Wed, Nov 14 2012 7:33 pm
Subject: Re: Dynamic sortBy

Thank you so much Ryan. it worked perfectly.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »