summaryrefslogtreecommitdiff
path: root/src/postgres.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2011-11-18 17:44:12 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2011-11-18 17:44:12 -0500
commit13eb7555000c10b0c54e11364c42e0da75b98ca7 (patch)
tree683cd859883db5175662045e278f0b10056e587a /src/postgres.sml
parentaabcc562d7ad7266b6b1e338a14a19224c1169df (diff)
Fix catalog querying about empty tables
Diffstat (limited to 'src/postgres.sml')
-rw-r--r--src/postgres.sml46
1 files changed, 24 insertions, 22 deletions
diff --git a/src/postgres.sml b/src/postgres.sml
index a66c85d9..f3b9e3f1 100644
--- a/src/postgres.sml
+++ b/src/postgres.sml
@@ -70,28 +70,30 @@ fun checkRel (table, checkNullable) (s, xts) =
val q' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE table_name = '",
sl,
"' AND (",
- String.concatWith " OR "
- (map (fn (x, t) =>
- String.concat ["(column_name = 'uw_",
- CharVector.map
- Char.toLower (ident x),
- (case p_sql_type_base t of
- "bigint" =>
- "' AND data_type IN ('bigint', 'numeric')"
- | t =>
- String.concat ["' AND data_type = '",
- 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 = 'uw_",
+ CharVector.map
+ Char.toLower (ident x),
+ (case p_sql_type_base t of
+ "bigint" =>
+ "' AND data_type IN ('bigint', 'numeric')"
+ | t =>
+ String.concat ["' AND data_type = '",
+ 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 table_name = '",