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
commit8e0703aba307782b43ed591acbb7c574859a22c3 (patch)
tree683cd859883db5175662045e278f0b10056e587a /src/postgres.sml
parent69e08bd046195515eed94d425ebd4cf549d5a549 (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 = '",