changeset 708:1a317a707d71

Add primary keys to demo
author Adam Chlipala <adamc@hcoop.net>
date Tue, 07 Apr 2009 16:22:11 -0400
parents d8217b4cb617
children 0406e9cccb72
files demo/batch.ur demo/batchG.ur demo/broadcast.ur demo/chat.ur demo/crud1.ur demo/crud2.ur demo/noisy.ur demo/refFun.ur demo/roundTrip.ur demo/sql.ur demo/tree.ur src/elisp/urweb-mode.el
diffstat 12 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/demo/batch.ur	Tue Apr 07 16:14:31 2009 -0400
+++ b/demo/batch.ur	Tue Apr 07 16:22:11 2009 -0400
@@ -1,6 +1,7 @@
 datatype list t = Nil | Cons of t * list t
 
 table t : {Id : int, A : string}
+  PRIMARY KEY Id
 
 fun allRows () =
     query (SELECT * FROM t)
--- a/demo/batchG.ur	Tue Apr 07 16:14:31 2009 -0400
+++ b/demo/batchG.ur	Tue Apr 07 16:22:11 2009 -0400
@@ -1,4 +1,5 @@
 table t : {Id : int, A : string, B : float}
+  PRIMARY KEY Id
 
 open BatchFun.Make(struct
                        val tab = t
--- a/demo/broadcast.ur	Tue Apr 07 16:14:31 2009 -0400
+++ b/demo/broadcast.ur	Tue Apr 07 16:22:11 2009 -0400
@@ -1,6 +1,7 @@
 functor Make(M : sig type t end) = struct
     sequence s
     table t : {Id : int, Client : client, Channel : channel M.t}
+      PRIMARY KEY Id
 
     type topic = int
 
--- a/demo/chat.ur	Tue Apr 07 16:14:31 2009 -0400
+++ b/demo/chat.ur	Tue Apr 07 16:22:11 2009 -0400
@@ -4,6 +4,7 @@
 
 sequence s
 table t : { Id : int, Title : string, Room : Room.topic }
+  PRIMARY KEY Id
 
 fun chat id =
     r <- oneRow (SELECT t.Title, t.Room FROM t WHERE t.Id = {[id]});
--- a/demo/crud1.ur	Tue Apr 07 16:14:31 2009 -0400
+++ b/demo/crud1.ur	Tue Apr 07 16:22:11 2009 -0400
@@ -1,4 +1,5 @@
 table t1 : {Id : int, A : int, B : string, C : float, D : bool}
+  PRIMARY KEY Id
 
 open Crud.Make(struct
                    val tab = t1
--- a/demo/crud2.ur	Tue Apr 07 16:14:31 2009 -0400
+++ b/demo/crud2.ur	Tue Apr 07 16:22:11 2009 -0400
@@ -1,4 +1,5 @@
 table t : {Id : int, Nam : string, Ready : bool}
+  PRIMARY KEY Id
 
 open Crud.Make(struct
                    val tab = t
--- a/demo/noisy.ur	Tue Apr 07 16:14:31 2009 -0400
+++ b/demo/noisy.ur	Tue Apr 07 16:22:11 2009 -0400
@@ -1,6 +1,7 @@
 datatype list t = Nil | Cons of t * list t
 
 table t : { Id : int, A : string }
+  PRIMARY KEY Id
 
 fun add id s =
     dml (INSERT INTO t (Id, A) VALUES ({[id]}, {[s]}))
--- a/demo/refFun.ur	Tue Apr 07 16:14:31 2009 -0400
+++ b/demo/refFun.ur	Tue Apr 07 16:22:11 2009 -0400
@@ -7,6 +7,7 @@
 
     sequence s
     table t : { Id : int, Data : M.data }
+      PRIMARY KEY Id
 
     fun new d =
         id <- nextval s;
--- a/demo/roundTrip.ur	Tue Apr 07 16:14:31 2009 -0400
+++ b/demo/roundTrip.ur	Tue Apr 07 16:22:11 2009 -0400
@@ -1,4 +1,5 @@
 table channels : { Client : client, Channel : channel (string * int * float) }
+  PRIMARY KEY Client
 
 fun writeBack v =
     me <- self;
--- a/demo/sql.ur	Tue Apr 07 16:14:31 2009 -0400
+++ b/demo/sql.ur	Tue Apr 07 16:22:11 2009 -0400
@@ -1,4 +1,5 @@
 table t : { A : int, B : float, C : string, D : bool }
+  PRIMARY KEY A
 
 fun list () =
     rows <- queryX (SELECT * FROM t)
--- a/demo/tree.ur	Tue Apr 07 16:14:31 2009 -0400
+++ b/demo/tree.ur	Tue Apr 07 16:22:11 2009 -0400
@@ -1,5 +1,6 @@
 sequence s
 table t : { Id : int, Parent : option int, Nam : string }
+  PRIMARY KEY Id
 
 open TreeFun.Make(struct
                       val tab = t
--- a/src/elisp/urweb-mode.el	Tue Apr 07 16:14:31 2009 -0400
+++ b/src/elisp/urweb-mode.el	Tue Apr 07 16:22:11 2009 -0400
@@ -147,7 +147,8 @@
   (urweb-syms-re "SELECT" "FROM" "AS" "WHERE" "SQL" "GROUP" "ORDER" "BY"
                  "HAVING" "LIMIT" "OFFSET" "ALL" "UNION" "INTERSECT" "EXCEPT"
                  "TRUE" "FALSE" "AND" "OR" "NOT" "COUNT" "AVG" "SUM" "MIN" "MAX"
-                 "ASC" "DESC" "INSERT" "INTO" "VALUES" "UPDATE" "SET" "DELETE")
+                 "ASC" "DESC" "INSERT" "INTO" "VALUES" "UPDATE" "SET" "DELETE"
+                 "PRIMARY" "KEY" "CONSTRAINT" "UNIQUE")
   "A regexp that matches SQL keywords.")
 
 (defconst urweb-lident-regexp "\\<[a-z_][A-Za-z0-9_']*\\>"