diff options
author | Ziv Scully <ziv@mit.edu> | 2015-11-19 03:45:39 -0500 |
---|---|---|
committer | Ziv Scully <ziv@mit.edu> | 2015-11-19 03:45:39 -0500 |
commit | 0c231060050adf556348b06f078c994f4a0e65b4 (patch) | |
tree | f88b73ae276f7df0a9a7543b8d9569312d9fb2a5 /src/sqlcache.sml | |
parent | bfcd84434ee997b474935aa13ae7bc1f3801d795 (diff) |
Fix SQL parser JOIN bug and fix ON clause logic in Sqlcache.
Diffstat (limited to 'src/sqlcache.sml')
-rw-r--r-- | src/sqlcache.sml | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/sqlcache.sml b/src/sqlcache.sml index 9ff7c61d..ce5ad5f5 100644 --- a/src/sqlcache.sml +++ b/src/sqlcache.sml @@ -823,9 +823,12 @@ structure FlattenQuery = struct | Sql.Join (jt, fi1, fi2, se) => concatMap (fn ((wher1, subst1)) => map (fn (wher2, subst2) => - (sqlAnd (wher1, wher2), - (* There should be no name conflicts... Ziv hopes? *) - unionSubst (subst1, subst2))) + let + val subst = unionSubst (subst1, subst2) + in + (* ON clause becomes part of the accumulated WHERE. *) + (sqlAnd (sqlAnd (wher1, wher2), applySubst subst se), subst) + end) (flattenFitem fi2)) (flattenFitem fi1) @@ -1362,14 +1365,13 @@ fun cacheQuery (effs, env, q) : subexp = val {query = queryText, initial, body, ...} = q val attempt = (* Ziv misses Haskell's do notation.... *) - (safe 0 (printExp "attempt" queryText) andalso safe 0 initial andalso safe 2 body) + (safe 0 queryText andalso safe 0 initial andalso safe 2 body) <\oguard\> (fn _ => - Sql.parse Sql.query (printExp "safe" queryText) + Sql.parse Sql.query queryText <\obind\> (fn queryParsed => let - val _ = (printExp "parsed" queryText) val invalInfo = InvalInfo.singleton queryParsed fun mkExp state = case cacheExp (env, EQuery q, invalInfo, state) of |