Created
May 25, 2019 06:47
-
-
Save karthik20522/ee21e0f6311ba42c4fb0e8f087a98fb8 to your computer and use it in GitHub Desktop.
select * from users order by age desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class Direction | |
case class Asc(field: String*) extends Direction | |
case class Desc(field: String*) extends Direction | |
def order: Parser[Direction] = { | |
"order" ~> "by" ~> ident ~ ("asc" | "desc") ^^ { | |
case f ~ "asc" => Asc(f) | |
case f ~ "desc" => Desc(f) | |
} | |
} | |
//output: Desc("age") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment