diff src/settings.sml @ 1953:0992323fa264

noMangleSql .urp directive
author Adam Chlipala <adam@chlipala.net>
date Sat, 04 Jan 2014 19:02:14 -0500
parents cf7f7e51b0a2
children ac1be85e91ad
line wrap: on
line diff
--- a/src/settings.sml	Wed Jan 01 10:51:47 2014 -0500
+++ b/src/settings.sml	Sat Jan 04 19:02:14 2014 -0500
@@ -696,4 +696,24 @@
 fun setTimeFormat v = timeFormat := v
 fun getTimeFormat () = !timeFormat
 
+fun lowercase s =
+    case s of
+        "" => ""
+      | _ => str (Char.toLower (String.sub (s, 0))) ^ String.extract (s, 1, NONE)
+
+fun capitalize s =
+    case s of
+        "" => ""
+      | _ => str (Char.toUpper (String.sub (s, 0))) ^ String.extract (s, 1, NONE)
+
+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
+
 end