diff options
-rw-r--r-- | src/mysql.sml | 42 | ||||
-rw-r--r-- | src/postgres.sml | 46 | ||||
-rw-r--r-- | tests/emptyTable.ur | 1 | ||||
-rw-r--r-- | tests/emptyTable.urp | 4 |
4 files changed, 51 insertions, 42 deletions
diff --git a/src/mysql.sml b/src/mysql.sml index a8a10da7..0715d253 100644 --- a/src/mysql.sml +++ b/src/mysql.sml @@ -83,26 +83,28 @@ fun checkRel (table, checkNullable) (s, xts) = 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 ", 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 = '", diff --git a/tests/emptyTable.ur b/tests/emptyTable.ur new file mode 100644 index 00000000..d9469be4 --- /dev/null +++ b/tests/emptyTable.ur @@ -0,0 +1 @@ +table tricky : {} diff --git a/tests/emptyTable.urp b/tests/emptyTable.urp new file mode 100644 index 00000000..c8a7ca25 --- /dev/null +++ b/tests/emptyTable.urp @@ -0,0 +1,4 @@ +database dbname=test +sql emptyTable.sql + +emptyTable |