This PR resolves an issue with `tablemodelview/api/read` which throws the 
following exception,
```
TypeError: Object of type Database is not JSON serializable
```
i.e., it's trying to to serialize the `Database` object to JSON which is 
defined as one of the FAB `list_columns`. The remedy is to simply reference the 
`Database.name` attribute as opposed to the `Database` object. 

Attached is a screenshot, note I've kept the label unchanged so the UI remains 
unchanged:

![screenshot](https://user-images.githubusercontent.com/4567245/46379066-8d988100-c652-11e8-97e8-4a80bc644440.png)

and here's the corresponding API response (truncated):
```
{
  "count": 11, 
  "label_columns": {
    "cache_timeout": "Cache Timeout", 
    "changed_by": "Changed By", 
    "changed_by_": "Changed By", 
    "changed_by_fk": "Changed By Fk", 
    "changed_on": "Changed On", 
    "changed_on_": "Last Changed", 
    "columns": "Columns", 
    "created_by": "Created By", 
    "created_by_fk": "Created By Fk", 
    "created_on": "Created On", 
    "database": "Database", 
    "database_id": "Database Id", 
    "database_name": "Database", 
    "default_endpoint": "Default Endpoint", 
    "description": "Description", 
    "fetch_values_predicate": "Fetch Values Predicate", 
    "filter_select_enabled": "Enable Filter Select", 
    "id": "Id", 
    "is_featured": "Is Featured", 
    "is_sqllab_view": "SQL Lab View", 
    "link": "Table", 
    "main_dttm_col": "Main Datetime Column", 
    "metrics": "Metrics", 
    "modified": "Modified", 
    "offset": "Offset", 
    "owner": "Owner", 
    "params": "Params", 
    "perm": "Perm", 
    "schema": "Schema", 
    "slices": "Associated Charts", 
    "sql": "Sql", 
    "table_name": "Table Name", 
    "template_params": "Template parameters", 
    "user_id": "User Id"
  }, 
  "list_columns": [
    "link", 
    "database_name", 
    "changed_by_", 
    "modified"
  ], 
  "modelview_name": "TableModelView", 
  "order_columns": [
    "modified"
  ], 
  "page": null, 
  "page_size": null, 
  "pks": [
    1, 
    2, 
    3, 
    4, 
    5, 
    6, 
    7, 
    8, 
    9, 
    10, 
    11
  ], 
  "result": [
    {
      "changed_by_": "", 
      "database_name": "main", 
      "link": "<a target=\"_blank\" 
href=\"/superset/explore/table/1/\">energy_usage</a>", 
      "modified": "an hour ago"
    }, 
   ...
```

to: @michellethomas @mistercrunch 
cc: @graceguo-supercat @timifasubaa 

[ Full content available at: 
https://github.com/apache/incubator-superset/pull/6023 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to