diff src/mysql.sml @ 1600:8128fcb2d4a4

Fix catalog querying about empty tables
author Adam Chlipala <adam@chlipala.net>
date Fri, 18 Nov 2011 17:44:12 -0500
parents 969b90b1f2f9
children 3e7c7e200713
line wrap: on
line diff
--- a/src/mysql.sml	Fri Nov 18 17:17:22 2011 -0500
+++ b/src/mysql.sml	Fri Nov 18 17:44:12 2011 -0500
@@ -83,26 +83,28 @@
         val q' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE ",
                                 both,
                                 " AND (",
-                                String.concatWith " OR "
-                                                  (map (fn (x, t) =>
-                                                           String.concat ["(column_name IN ('uw_",
-                                                                          CharVector.map
-                                                                              Char.toLower (ident x),
-                                                                          "', 'uw_",
-                                                                          ident x,
-                                                                          "') AND data_type = '",
-                                                                          p_sql_type_base t,
-                                                                          "'",
-                                                                          if checkNullable then
-                                                                              (" AND is_nullable = '"
-                                                                               ^ (if isNotNull t then
-                                                                                      "NO"
-                                                                                  else
-                                                                                      "YES")
-                                                                               ^ "'")
-                                                                          else
-                                                                              "",
-                                                                          ")"]) xts),
+                                case String.concatWith " OR "
+                                                       (map (fn (x, t) =>
+                                                                String.concat ["(column_name IN ('uw_",
+                                                                               CharVector.map
+                                                                                   Char.toLower (ident x),
+                                                                               "', 'uw_",
+                                                                               ident x,
+                                                                               "') AND data_type = '",
+                                                                               p_sql_type_base t,
+                                                                               "'",
+                                                                               if checkNullable then
+                                                                                   (" AND is_nullable = '"
+                                                                                    ^ (if isNotNull t then
+                                                                                           "NO"
+                                                                                       else
+                                                                                           "YES")
+                                                                                    ^ "'")
+                                                                               else
+                                                                                   "",
+                                                                               ")"]) xts) of
+                                    "" => "FALSE"
+                                  | s => s,
                                 ")"]
 
         val q'' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE ",