Mercurial > urweb
changeset 231:eadeea528f75
LIMIT
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 21 Aug 2008 16:00:01 -0400 |
parents | 87d41ac28b30 |
children | a338da9d82f3 |
files | lib/basis.lig src/lacweb.grm src/lacweb.lex tests/limit.lac |
diffstat | 4 files changed, 29 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/basis.lig Thu Aug 21 15:50:08 2008 -0400 +++ b/lib/basis.lig Thu Aug 21 16:00:01 2008 -0400 @@ -60,10 +60,15 @@ -> sql_exp tables [] t -> sql_order_by tables -> sql_order_by tables +type sql_limit +val sql_no_limit : sql_limit +val sql_limit : int -> sql_limit + val sql_query : tables ::: {{Type}} -> selected ::: {{Type}} -> {Rows : sql_query1 tables selected, - OrderBy : sql_order_by tables} + OrderBy : sql_order_by tables, + Limit : sql_limit} -> sql_query selected val sql_field : otherTabs ::: {{Type}} -> otherFields ::: {Type} -> fieldType ::: Type -> agg ::: {{Type}}
--- a/src/lacweb.grm Thu Aug 21 15:50:08 2008 -0400 +++ b/src/lacweb.grm Thu Aug 21 16:00:01 2008 -0400 @@ -164,6 +164,7 @@ | SELECT | FROM | AS | CWHERE | GROUP | ORDER | BY | HAVING | UNION | INTERSECT | EXCEPT + | LIMIT | OFFSET | TRUE | FALSE | CAND | OR | NOT | NE | LT | LE | GT | GE @@ -245,6 +246,8 @@ | hopt of exp | obopt of exp | obexps of exp + | lopt of exp + | sqlint of exp %verbose (* print summary of errors *) @@ -658,13 +661,15 @@ | STRING (EPrim (Prim.String STRING), s (STRINGleft, STRINGright)) | LBRACE eexp RBRACE (eexp) -query : query1 obopt (let +query : query1 obopt lopt (let val loc = s (query1left, query1right) val re = (ERecord [((CName "Rows", loc), query1), ((CName "OrderBy", loc), - obopt)], loc) + obopt), + ((CName "Limit", loc), + lopt)], loc) in (EApp ((EVar (["Basis"], "sql_query"), loc), re), loc) end) @@ -844,3 +849,13 @@ in (EApp (e, obexps), loc) end) + +lopt : (EVar (["Basis"], "sql_no_limit"), dummy) + | LIMIT sqlint (let + val loc = s (LIMITleft, sqlintright) + in + (EApp ((EVar (["Basis"], "sql_limit"), loc), sqlint), loc) + end) + +sqlint : INT (EPrim (Prim.Int INT), s (INTleft, INTright)) + | LBRACE eexp RBRACE (eexp)
--- a/src/lacweb.lex Thu Aug 21 15:50:08 2008 -0400 +++ b/src/lacweb.lex Thu Aug 21 16:00:01 2008 -0400 @@ -309,6 +309,8 @@ <INITIAL> "ORDER" => (Tokens.ORDER (pos yypos, pos yypos + size yytext)); <INITIAL> "BY" => (Tokens.BY (pos yypos, pos yypos + size yytext)); <INITIAL> "HAVING" => (Tokens.HAVING (pos yypos, pos yypos + size yytext)); +<INITIAL> "LIMIT" => (Tokens.LIMIT (pos yypos, pos yypos + size yytext)); +<INITIAL> "OFFSET" => (Tokens.OFFSET (pos yypos, pos yypos + size yytext)); <INITIAL> "UNION" => (Tokens.UNION (pos yypos, pos yypos + size yytext)); <INITIAL> "INTERSECT" => (Tokens.INTERSECT (pos yypos, pos yypos + size yytext));