Mercurial > urweb
diff src/postgres.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 | da11f7b18067 |
children | 1bfd793e7eb8 |
line wrap: on
line diff
--- a/src/postgres.sml Fri Nov 18 17:17:22 2011 -0500 +++ b/src/postgres.sml Fri Nov 18 17:44:12 2011 -0500 @@ -70,28 +70,30 @@ 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 = '",