aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/mysql.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-10-12 18:16:42 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-10-12 18:16:42 -0400
commit84b3615abace2bd06c76e5d0ec6c5a8abe23a4de (patch)
treec69cea3cfdb3c557e95cda62758d48509109ea11 /src/mysql.sml
parent6529a13e560318d6c0d0521ed12a89b66d2e3e2a (diff)
Fix some MySQL hijinks
Diffstat (limited to 'src/mysql.sml')
-rw-r--r--src/mysql.sml22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/mysql.sml b/src/mysql.sml
index eba125c7..2941186c 100644
--- a/src/mysql.sml
+++ b/src/mysql.sml
@@ -73,19 +73,21 @@ val ident = String.translate (fn #"'" => "PRIME"
fun checkRel (table, checkNullable) (s, xts) =
let
val sl = CharVector.map Char.toLower s
+ val both = "table_name IN ('" ^ sl ^ "', '" ^ s ^ "')"
- val q = "SELECT COUNT(*) FROM information_schema." ^ table ^ " WHERE table_name = '"
- ^ sl ^ "'"
+ val q = "SELECT COUNT(*) FROM information_schema." ^ table ^ " WHERE " ^ both
- val q' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE table_name = '",
- sl,
- "' AND (",
+ val q' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE ",
+ both,
+ " AND (",
String.concatWith " OR "
(map (fn (x, t) =>
- String.concat ["(column_name = 'uw_",
+ String.concat ["(column_name IN ('uw_",
CharVector.map
Char.toLower (ident x),
- "' AND data_type = '",
+ "', 'uw_",
+ ident x,
+ "') AND data_type = '",
p_sql_type_base t,
"'",
if checkNullable then
@@ -100,9 +102,9 @@ fun checkRel (table, checkNullable) (s, xts) =
")"]) xts),
")"]
- val q'' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE table_name = '",
- sl,
- "' AND column_name LIKE 'uw_%'"]
+ val q'' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE ",
+ both,
+ " AND column_name LIKE 'uw_%'"]
in
box [string "if (mysql_query(conn->conn, \"",
string q,