Feat: Adding table comment and columns comment for SQLLab (#10844)

* Adding table comment and columns comment for backend

* fix mypy

* Fix CI

* adding wider catch

* use logger

* fix lint
This commit is contained in:
Yongjie Zhao
2020-09-15 12:11:48 +08:00
committed by GitHub
parent 4502690ef9
commit 38edb69d95
4 changed files with 33 additions and 0 deletions

View File

@@ -73,6 +73,7 @@ def get_table_metadata(
indexes = get_indexes_metadata(database, table_name, schema_name)
keys += foreign_keys + indexes
payload_columns: List[Dict[str, Any]] = []
table_comment = database.get_table_comment(table_name, schema_name)
for col in columns:
dtype = get_col_type(col)
payload_columns.append(
@@ -81,6 +82,7 @@ def get_table_metadata(
"type": dtype.split("(")[0] if "(" in dtype else dtype,
"longType": dtype,
"keys": [k for k in keys if col["name"] in k["column_names"]],
"comment": col.get("comment"),
}
)
return {
@@ -97,4 +99,5 @@ def get_table_metadata(
"primaryKey": primary_key,
"foreignKeys": foreign_keys,
"indexes": keys,
"comment": table_comment,
}