summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/manual.tex2
-rw-r--r--src/urweb.grm10
-rw-r--r--tests/pkeyEscape.ur6
-rw-r--r--tests/pkeyEscape.urp5
4 files changed, 19 insertions, 4 deletions
diff --git a/doc/manual.tex b/doc/manual.tex
index c18a594c..9f3e44a8 100644
--- a/doc/manual.tex
+++ b/doc/manual.tex
@@ -2113,7 +2113,7 @@ $\mt{table}$ declarations may include constraints, via these grammar rules.
$$\begin{array}{rrcll}
\textrm{Declarations} & d &::=& \mt{table} \; x : c \; [pk[,]] \; cts \mid \mt{view} \; x = V \\
\textrm{Primary key constraints} & pk &::=& \mt{PRIMARY} \; \mt{KEY} \; K \\
- \textrm{Keys} & K &::=& f \mid (f, (f,)^+) \\
+ \textrm{Keys} & K &::=& f \mid (f, (f,)^+) \mid \{\{e\}\} \\
\textrm{Constraint sets} & cts &::=& \mt{CONSTRAINT} f \; ct \mid cts, cts \mid \{\{e\}\} \\
\textrm{Constraints} & ct &::=& \mt{UNIQUE} \; K \mid \mt{CHECK} \; E \\
&&& \mid \mt{FOREIGN} \; \mt{KEY} \; K \; \mt{REFERENCES} \; F \; (K) \; [\mt{ON} \; \mt{DELETE} \; pr] \; [\mt{ON} \; \mt{UPDATE} \; pr] \\
diff --git a/src/urweb.grm b/src/urweb.grm
index 80e40bc3..c81ca9e6 100644
--- a/src/urweb.grm
+++ b/src/urweb.grm
@@ -300,6 +300,7 @@ fun tnamesOf (e, _) =
| dcon of string * con option
| pkopt of exp
+ | pk of exp
| commaOpt of unit
| cst of exp
@@ -707,9 +708,9 @@ pmodes : ([])
commaOpt: ()
| COMMA ()
-pkopt : (EVar (["Basis"], "no_primary_key", Infer), dummy)
- | PRIMARY KEY tnames (let
- val loc = s (PRIMARYleft, tnamesright)
+pk : LBRACE LBRACE eexp RBRACE RBRACE (eexp)
+ | tnames (let
+ val loc = s (tnamesleft, tnamesright)
val e = (EVar (["Basis"], "primary_key", TypesOnly), loc)
val e = (ECApp (e, #1 (#1 tnames)), loc)
@@ -725,6 +726,9 @@ pkopt : (EVar (["Basis"], "no_primary_key", Infe
(EApp (e, witness), loc)
end)
+pkopt : (EVar (["Basis"], "no_primary_key", Infer), dummy)
+ | PRIMARY KEY pk (pk)
+
valis : vali ([vali])
| vali AND valis (vali :: valis)
diff --git a/tests/pkeyEscape.ur b/tests/pkeyEscape.ur
new file mode 100644
index 00000000..c432b1e9
--- /dev/null
+++ b/tests/pkeyEscape.ur
@@ -0,0 +1,6 @@
+table t : {A : int, B : int}
+ PRIMARY KEY {{primary_key [#A] [[B = _]]}}
+
+fun main () : transaction page =
+ queryI (SELECT * FROM t) (fn _ => return ());
+ return <xml/>
diff --git a/tests/pkeyEscape.urp b/tests/pkeyEscape.urp
new file mode 100644
index 00000000..f041ed15
--- /dev/null
+++ b/tests/pkeyEscape.urp
@@ -0,0 +1,5 @@
+debug
+database dbname=pkeyEscape
+sql pkeyEscape.sql
+
+pkeyEscape