From 2babe3938c1d97e46be24e033d9cb575f746d80b Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Fri, 19 Aug 2011 14:20:24 -0400 Subject: Add antiquote for ORDER BY directions --- doc/manual.tex | 2 +- src/urweb.grm | 1 + tests/ascdesc.ur | 10 ++++++++++ tests/ascdesc.urp | 4 ++++ 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/ascdesc.ur create mode 100644 tests/ascdesc.urp diff --git a/doc/manual.tex b/doc/manual.tex index d00ad8ad..a1fe4a1d 100644 --- a/doc/manual.tex +++ b/doc/manual.tex @@ -2100,7 +2100,7 @@ $$\begin{array}{rrcll} \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 --git a/src/urweb.grm b/src/urweb.grm index f57f7a64..7a4d143f 100644 --- a/src/urweb.grm +++ b/src/urweb.grm @@ -1921,6 +1921,7 @@ obexps : obitem (let 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 --git a/tests/ascdesc.ur b/tests/ascdesc.ur new file mode 100644 index 00000000..59dd0169 --- /dev/null +++ b/tests/ascdesc.ur @@ -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 --git a/tests/ascdesc.urp b/tests/ascdesc.urp new file mode 100644 index 00000000..3e0b075d --- /dev/null +++ b/tests/ascdesc.urp @@ -0,0 +1,4 @@ +database dbname=test +sql ascdesc.sql + +ascdesc \ No newline at end of file -- cgit v1.2.3