# HG changeset patch # User Adam Chlipala # Date 1313778024 14400 # Node ID 6f046b4bad24049244941c96e4667ee37c718b05 # Parent dc4c61363d0ac159d3cc137e067763b5b33ba025 Add antiquote for ORDER BY directions diff -r dc4c61363d0a -r 6f046b4bad24 doc/manual.tex --- a/doc/manual.tex Fri Aug 19 08:59:01 2011 -0400 +++ b/doc/manual.tex Fri Aug 19 14:20:24 2011 -0400 @@ -2100,7 +2100,7 @@ \textrm{Unary operators} & u &::=& \mt{NOT} \\ \textrm{Binary operators} & b &::=& \mt{AND} \mid \mt{OR} \mid \neq \mid < \mid \leq \mid > \mid \geq \\ \textrm{Aggregate functions} & a &::=& \mt{COUNT} \mid \mt{AVG} \mid \mt{SUM} \mid \mt{MIN} \mid \mt{MAX} \\ - \textrm{Directions} & o &::=& \mt{ASC} \mid \mt{DESC} \\ + \textrm{Directions} & o &::=& \mt{ASC} \mid \mt{DESC} \mid \{e\} \\ \textrm{SQL integer} & N &::=& n \mid \{e\} \\ \end{array}$$ diff -r dc4c61363d0a -r 6f046b4bad24 src/urweb.grm --- a/src/urweb.grm Fri Aug 19 08:59:01 2011 -0400 +++ b/src/urweb.grm Fri Aug 19 14:20:24 2011 -0400 @@ -1921,6 +1921,7 @@ diropt : (EVar (["Basis"], "sql_asc", Infer), dummy) | ASC (EVar (["Basis"], "sql_asc", Infer), s (ASCleft, ASCright)) | DESC (EVar (["Basis"], "sql_desc", Infer), s (DESCleft, DESCright)) + | LBRACE eexp RBRACE (eexp) lopt : (EVar (["Basis"], "sql_no_limit", Infer), dummy) | LIMIT ALL (EVar (["Basis"], "sql_no_limit", Infer), dummy) diff -r dc4c61363d0a -r 6f046b4bad24 tests/ascdesc.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/ascdesc.ur Fri Aug 19 14:20:24 2011 -0400 @@ -0,0 +1,10 @@ +table t : { A : int } + +fun sortEm b = + queryX1 (SELECT * FROM t ORDER BY t.A {if b then sql_asc else sql_desc}) + (fn r => {[r.A]}; ) + +fun main () : transaction page = return + Ascending
+ Descending +
diff -r dc4c61363d0a -r 6f046b4bad24 tests/ascdesc.urp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/ascdesc.urp Fri Aug 19 14:20:24 2011 -0400 @@ -0,0 +1,4 @@ +database dbname=test +sql ascdesc.sql + +ascdesc \ No newline at end of file