Created
May 25, 2019 06:48
-
-
Save karthik20522/8d7e569d10f8b43e5675bc7be3ccf1ab to your computer and use it in GitHub Desktop.
select * from users order by name, 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) | |
}) | ("order" ~> "by" ~> repsep(ident, ",") ~ ("asc" | "desc") ^^ { | |
case f ~ "asc" => Asc(f: _*) | |
case f ~ "desc" => Desc(f: _*) | |
}) | |
} | |
//output: Desc("name", "age") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment