changeset 2108:1f1575eff4b9

Fix case issue in name mangling for MySQL
author Adam Chlipala <adam@chlipala.net>
date Thu, 22 Jan 2015 11:26:24 -0500
parents 6700f3700328
children f42fea631c1d
files src/settings.sml
diffstat 1 files changed, 38 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/settings.sml	Thu Jan 22 11:00:17 2015 -0500
+++ b/src/settings.sml	Thu Jan 22 11:26:24 2015 -0500
@@ -744,15 +744,46 @@
         "" => ""
       | _ => str (Char.toUpper (String.sub (s, 0))) ^ String.extract (s, 1, NONE)
 
+val allLower = CharVector.map Char.toLower
+
 val mangle = ref true
 fun setMangleSql x = mangle := x
-fun mangleSqlTable s = if !mangle then "uw_" ^ capitalize s
-                       else if #name (currentDbms ()) = "mysql" then capitalize s
-                       else lowercase s
-fun mangleSql s = if !mangle then "uw_" ^ s
-                  else if #name (currentDbms ()) = "mysql" then lowercase s
-                  else lowercase s
-fun mangleSqlCatalog s = if !mangle then "uw_" ^ s else lowercase s
+
+fun mangleSqlTable s =
+    if #name (currentDbms ()) = "mysql" then
+        if !mangle then
+            "uw_" ^ allLower s
+        else
+            allLower s
+    else
+        if !mangle then
+            "uw_" ^ capitalize s
+        else
+            lowercase s
+
+fun mangleSql s =
+    if #name (currentDbms ()) = "mysql" then
+        if !mangle then
+            "uw_" ^ allLower s 
+        else
+            allLower s
+    else
+        if !mangle then
+            "uw_" ^ s
+        else
+            lowercase s
+
+fun mangleSqlCatalog s =
+    if #name (currentDbms ()) = "mysql" then
+        if !mangle then
+            "uw_" ^ allLower s
+        else
+            allLower s
+    else
+        if !mangle then
+            "uw_" ^ s
+        else
+            lowercase s
 
 val html5 = ref false
 fun setIsHtml5 b = html5 := b