cov: remove unused fields from type Column
This commit is contained in:
committed by
Wolfgang Walther
parent
b8e6450af1
commit
d173b7d8d6
@@ -80,12 +80,13 @@ decodeColumns tables =
|
|||||||
mapMaybe (columnFromRow tables) <$> HD.rowList colRow
|
mapMaybe (columnFromRow tables) <$> HD.rowList colRow
|
||||||
where
|
where
|
||||||
colRow =
|
colRow =
|
||||||
(,,,,,,,,,,,)
|
(,,,,,,,,)
|
||||||
<$> column HD.text <*> column HD.text
|
<$> column HD.text
|
||||||
<*> column HD.text <*> nullableColumn HD.text
|
<*> column HD.text
|
||||||
<*> column HD.int4 <*> column HD.bool
|
<*> column HD.text
|
||||||
<*> column HD.text <*> column HD.bool
|
<*> nullableColumn HD.text
|
||||||
<*> nullableColumn HD.int4
|
<*> column HD.bool
|
||||||
|
<*> column HD.text
|
||||||
<*> nullableColumn HD.int4
|
<*> nullableColumn HD.int4
|
||||||
<*> nullableColumn HD.text
|
<*> nullableColumn HD.text
|
||||||
<*> nullableColumn HD.text
|
<*> nullableColumn HD.text
|
||||||
@@ -433,14 +434,12 @@ allColumns tabs =
|
|||||||
info.table_name AS table_name,
|
info.table_name AS table_name,
|
||||||
info.column_name AS name,
|
info.column_name AS name,
|
||||||
info.description AS description,
|
info.description AS description,
|
||||||
info.ordinal_position AS position,
|
|
||||||
info.is_nullable::boolean AS nullable,
|
info.is_nullable::boolean AS nullable,
|
||||||
info.data_type AS col_type,
|
info.data_type AS col_type,
|
||||||
info.is_updatable::boolean AS updatable,
|
|
||||||
info.character_maximum_length AS max_len,
|
info.character_maximum_length AS max_len,
|
||||||
info.numeric_precision AS precision,
|
|
||||||
info.column_default AS default_value,
|
info.column_default AS default_value,
|
||||||
array_to_string(enum_info.vals, ',') AS enum
|
array_to_string(enum_info.vals, ',') AS enum,
|
||||||
|
info.position
|
||||||
FROM (
|
FROM (
|
||||||
-- CTE based on pg_catalog to get PRIMARY/FOREIGN key and UNIQUE columns outside api schema
|
-- CTE based on pg_catalog to get PRIMARY/FOREIGN key and UNIQUE columns outside api schema
|
||||||
WITH key_columns AS (
|
WITH key_columns AS (
|
||||||
@@ -475,7 +474,6 @@ allColumns tabs =
|
|||||||
c.relname::name AS table_name,
|
c.relname::name AS table_name,
|
||||||
a.attname::name AS column_name,
|
a.attname::name AS column_name,
|
||||||
d.description AS description,
|
d.description AS description,
|
||||||
a.attnum::integer AS ordinal_position,
|
|
||||||
pg_get_expr(ad.adbin, ad.adrelid)::text AS column_default,
|
pg_get_expr(ad.adbin, ad.adrelid)::text AS column_default,
|
||||||
not (a.attnotnull OR t.typtype = 'd' AND t.typnotnull) AS is_nullable,
|
not (a.attnotnull OR t.typtype = 'd' AND t.typnotnull) AS is_nullable,
|
||||||
CASE
|
CASE
|
||||||
@@ -496,15 +494,8 @@ allColumns tabs =
|
|||||||
information_schema._pg_truetypid(a.*, t.*),
|
information_schema._pg_truetypid(a.*, t.*),
|
||||||
information_schema._pg_truetypmod(a.*, t.*)
|
information_schema._pg_truetypmod(a.*, t.*)
|
||||||
)::integer AS character_maximum_length,
|
)::integer AS character_maximum_length,
|
||||||
information_schema._pg_numeric_precision(
|
|
||||||
information_schema._pg_truetypid(a.*, t.*),
|
|
||||||
information_schema._pg_truetypmod(a.*, t.*)
|
|
||||||
)::integer AS numeric_precision,
|
|
||||||
COALESCE(bt.typname, t.typname)::name AS udt_name,
|
COALESCE(bt.typname, t.typname)::name AS udt_name,
|
||||||
(
|
a.attnum::integer AS position
|
||||||
c.relkind in ('r', 'v', 'f')
|
|
||||||
AND pg_column_is_updatable(c.oid::regclass, a.attnum, false)
|
|
||||||
)::bool is_updatable
|
|
||||||
FROM pg_attribute a
|
FROM pg_attribute a
|
||||||
LEFT JOIN key_columns kc
|
LEFT JOIN key_columns kc
|
||||||
ON kc.conkey = a.attnum AND kc.c_oid = a.attrelid
|
ON kc.conkey = a.attnum AND kc.c_oid = a.attrelid
|
||||||
@@ -533,14 +524,12 @@ allColumns tabs =
|
|||||||
table_name,
|
table_name,
|
||||||
column_name,
|
column_name,
|
||||||
description,
|
description,
|
||||||
ordinal_position,
|
|
||||||
is_nullable,
|
is_nullable,
|
||||||
data_type,
|
data_type,
|
||||||
is_updatable,
|
|
||||||
character_maximum_length,
|
character_maximum_length,
|
||||||
numeric_precision,
|
|
||||||
column_default,
|
column_default,
|
||||||
udt_name
|
udt_name,
|
||||||
|
position
|
||||||
FROM columns
|
FROM columns
|
||||||
WHERE table_schema NOT IN ('pg_catalog', 'information_schema')
|
WHERE table_schema NOT IN ('pg_catalog', 'information_schema')
|
||||||
) AS info
|
) AS info
|
||||||
@@ -558,13 +547,12 @@ allColumns tabs =
|
|||||||
|
|
||||||
columnFromRow :: [Table] ->
|
columnFromRow :: [Table] ->
|
||||||
(Text, Text, Text,
|
(Text, Text, Text,
|
||||||
Maybe Text, Int32, Bool,
|
Maybe Text, Bool, Text,
|
||||||
Text, Bool, Maybe Int32,
|
|
||||||
Maybe Int32, Maybe Text, Maybe Text)
|
Maybe Int32, Maybe Text, Maybe Text)
|
||||||
-> Maybe Column
|
-> Maybe Column
|
||||||
columnFromRow tabs (s, t, n, desc, pos, nul, typ, u, l, p, d, e) = buildColumn <$> table
|
columnFromRow tabs (s, t, n, desc, nul, typ, l, d, e) = buildColumn <$> table
|
||||||
where
|
where
|
||||||
buildColumn tbl = Column tbl n desc pos nul typ u l p d (parseEnum e) Nothing
|
buildColumn tbl = Column tbl n desc nul typ l d (parseEnum e) Nothing
|
||||||
table = find (\tbl -> tableSchema tbl == s && tableName tbl == t) tabs
|
table = find (\tbl -> tableSchema tbl == s && tableName tbl == t) tabs
|
||||||
parseEnum :: Maybe Text -> [Text]
|
parseEnum :: Maybe Text -> [Text]
|
||||||
parseEnum = maybe [] (split (==','))
|
parseEnum = maybe [] (split (==','))
|
||||||
|
|||||||
@@ -241,12 +241,9 @@ data Column =
|
|||||||
colTable :: Table
|
colTable :: Table
|
||||||
, colName :: FieldName
|
, colName :: FieldName
|
||||||
, colDescription :: Maybe Text
|
, colDescription :: Maybe Text
|
||||||
, colPosition :: Int32
|
|
||||||
, colNullable :: Bool
|
, colNullable :: Bool
|
||||||
, colType :: Text
|
, colType :: Text
|
||||||
, colUpdatable :: Bool
|
|
||||||
, colMaxLen :: Maybe Int32
|
, colMaxLen :: Maybe Int32
|
||||||
, colPrecision :: Maybe Int32
|
|
||||||
, colDefault :: Maybe Text
|
, colDefault :: Maybe Text
|
||||||
, colEnum :: [Text]
|
, colEnum :: [Text]
|
||||||
, colFK :: Maybe ForeignKey
|
, colFK :: Maybe ForeignKey
|
||||||
|
|||||||
Reference in New Issue
Block a user