aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2011-08-19 14:20:24 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2011-08-19 14:20:24 -0400
commit2babe3938c1d97e46be24e033d9cb575f746d80b (patch)
tree171d4a50ae25c43824224d1cf7bf418b16de314c
parentafaf7f27220ccc94b3bb29fb14994040e97b1f4e (diff)
Add antiquote for ORDER BY directions
-rw-r--r--doc/manual.tex2
-rw-r--r--src/urweb.grm1
-rw-r--r--tests/ascdesc.ur10
-rw-r--r--tests/ascdesc.urp4
4 files changed, 16 insertions, 1 deletions
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 => <xml>{[r.A]}; </xml>)
+
+fun main () : transaction page = return <xml><body>
+ <a link={sortEm True}>Ascending</a><br/>
+ <a link={sortEm False}>Descending</a>
+</body></xml>
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