# HG changeset patch # User Adam Chlipala # Date 1220211375 14400 # Node ID d1b679dbbc251dadea120f7709b3e41e3e6f75fe # Parent 40c33706d887a8e9145435c3fc47143996fa0c5a Monoize HAVING diff -r 40c33706d887 -r d1b679dbbc25 src/mono_opt.sml --- a/src/mono_opt.sml Sun Aug 31 15:32:31 2008 -0400 +++ b/src/mono_opt.sml Sun Aug 31 15:36:15 2008 -0400 @@ -84,7 +84,9 @@ val sqlifyInt = attrifyInt val sqlifyFloat = attrifyFloat -fun sqlifyString s = "E'" ^ String.toString s ^ "'" +fun sqlifyString s = "E'" ^ String.translate (fn #"'" => "\\'" + | ch => str ch) + (String.toString s) ^ "'" fun exp e = case e of diff -r 40c33706d887 -r d1b679dbbc25 src/monoize.sml --- a/src/monoize.sml Sun Aug 31 15:32:31 2008 -0400 +++ b/src/monoize.sml Sun Aug 31 15:36:15 2008 -0400 @@ -637,7 +637,15 @@ (map (fn (x', _) => sc (x ^ "." ^ x')) xts)) grouped) - ] + ], + + (L'.ECase (gf "Having", + [((L'.PPrim (Prim.String "TRUE"), loc), + sc ""), + ((L'.PWild, loc), + strcat loc [sc " HAVING ", gf "Having"])], + {disc = s, + result = s}), loc) ]), loc), fm) | _ => poly () diff -r 40c33706d887 -r d1b679dbbc25 tests/group_by.ur --- a/tests/group_by.ur Sun Aug 31 15:32:31 2008 -0400 +++ b/tests/group_by.ur Sun Aug 31 15:36:15 2008 -0400 @@ -5,7 +5,7 @@ val q2 = (SELECT * FROM t1, t2 GROUP BY t1.B, t2.D, t1.A) val q3 = (SELECT * FROM t1 WHERE t1.A = 0 GROUP BY t1.B) -val q4 = (SELECT * FROM t1 WHERE t1.A = 0 GROUP BY t1.C HAVING t1.C < 0.2) +val q4 = (SELECT * FROM t1 WHERE t1.A = 0 GROUP BY t1.B HAVING t1.B <> 'Bad') val q5 = (SELECT t1.A, t2.D FROM t1, t2 GROUP BY t2.D, t1.A) val q6 = (SELECT t1.A, t2.D FROM t1, t2 WHERE t1.C = 0.0 GROUP BY t2.D, t1.A HAVING t1.A = t1.A AND t2.D = 17) @@ -14,7 +14,7 @@ datatype list a = Nil | Cons of a * list a val r1 : transaction (list {B : string}) = - query q1 + query q4 (fn fs acc => return (Cons (fs.T1, acc))) Nil