Mercurial > urweb
comparison src/sql.sml @ 2295:e6c5bb62fef8
Fix SQL parser JOIN bug and fix ON clause logic in Sqlcache.
author | Ziv Scully <ziv@mit.edu> |
---|---|
date | Thu, 19 Nov 2015 03:45:39 -0500 |
parents | f8903af753ff |
children |
comparison
equal
deleted
inserted
replaced
2294:f8903af753ff | 2295:e6c5bb62fef8 |
---|---|
382 (wrap (follow (const "SELECT ") (list sitem)) | 382 (wrap (follow (const "SELECT ") (list sitem)) |
383 (fn ((), ls) => ls)) | 383 (fn ((), ls) => ls)) |
384 | 384 |
385 datatype jtype = Inner | Left | Right | Full | 385 datatype jtype = Inner | Left | Right | Full |
386 | 386 |
387 val jtype = wrap (ws (follow (opt (altL [wrap (const "LEFT") (fn () => Left), | |
388 wrap (const "RIGHT") (fn () => Right), | |
389 wrap (const "FULL") (fn () => Full)])) | |
390 (const " JOIN "))) | |
391 (fn (SOME jt, ()) => jt | (NONE, ()) => Inner) | |
392 | |
393 datatype fitem = | 387 datatype fitem = |
394 Table of string * string (* table AS name *) | 388 Table of string * string (* table AS name *) |
395 | Join of jtype * fitem * fitem * sqexp | 389 | Join of jtype * fitem * fitem * sqexp |
396 | Nested of query * string (* query AS name *) | 390 | Nested of query * string (* query AS name *) |
397 | 391 |
402 val wher = wrap (follow (ws (const "WHERE ")) sqexp) | 396 val wher = wrap (follow (ws (const "WHERE ")) sqexp) |
403 (fn ((), ls) => ls) | 397 (fn ((), ls) => ls) |
404 | 398 |
405 val orderby = log "orderby" | 399 val orderby = log "orderby" |
406 (wrap (follow (ws (const "ORDER BY ")) | 400 (wrap (follow (ws (const "ORDER BY ")) |
407 (follow (list sqexp) | 401 (list (follow sqexp |
408 (opt (ws (const "DESC"))))) | 402 (opt (ws (const "DESC")))))) |
409 ignore) | 403 ignore) |
404 | |
405 val jtype = altL [wrap (const "JOIN") (fn () => Inner), | |
406 wrap (const "LEFT JOIN") (fn () => Left), | |
407 wrap (const "RIGHT JOIN") (fn () => Right), | |
408 wrap (const "FULL JOIN") (fn () => Full)] | |
410 | 409 |
411 fun fitem chs = altL [wrap (follow uw_ident | 410 fun fitem chs = altL [wrap (follow uw_ident |
412 (follow (const " AS ") | 411 (follow (const " AS ") |
413 t_ident)) | 412 t_ident)) |
414 (fn (t, ((), f)) => Table (t, f)), | 413 (fn (t, ((), f)) => Table (t, f)), |
415 wrap (follow (const "(") | 414 wrap (follow (const "(") |
416 (follow fitem | 415 (follow fitem |
417 (follow jtype | 416 (follow (ws jtype) |
418 (follow fitem | 417 (follow fitem |
419 (follow (const " ON ") | 418 (follow (const " ON ") |
420 (follow sqexp | 419 (follow sqexp |
421 (const ")"))))))) | 420 (const ")"))))))) |
422 (fn ((), (fi1, (jt, (fi2, ((), (se, ())))))) => | 421 (fn ((), (fi1, (jt, (fi2, ((), (se, ())))))) => |