superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject [incubator-superset] branch master updated: Fix annotation_json endpoint (#5621)
Date Tue, 14 Aug 2018 18:40:17 GMT
This is an automated email from the ASF dual-hosted git repository.

hugh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 85a6da1  Fix annotation_json endpoint (#5621)
85a6da1 is described below

commit 85a6da19ee598605f63b557c69620052d3e04ad0
Author: Hugh A. Miles II <hughmil3s@gmail.com>
AuthorDate: Tue Aug 14 11:40:14 2018 -0700

    Fix annotation_json endpoint (#5621)
    
    * fix annotation_json endpoint
    
    * add time back
    
    * set db to None
    
    * change if condition
    
    * remove prop
    
    * add guard for to_dttm
    
    * linting
---
 superset/connectors/sqla/models.py | 6 ++++--
 superset/viz.py                    | 3 ++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py
index 61483cc..648bff4 100644
--- a/superset/connectors/sqla/models.py
+++ b/superset/connectors/sqla/models.py
@@ -47,8 +47,10 @@ class AnnotationDatasource(BaseDatasource):
         error_message = None
         qry = db.session.query(Annotation)
         qry = qry.filter(Annotation.layer_id == query_obj['filter'][0]['val'])
-        qry = qry.filter(Annotation.start_dttm >= query_obj['from_dttm'])
-        qry = qry.filter(Annotation.end_dttm <= query_obj['to_dttm'])
+        if query_obj['from_dttm']:
+            qry = qry.filter(Annotation.start_dttm >= query_obj['from_dttm'])
+        if query_obj['to_dttm']:
+            qry = qry.filter(Annotation.end_dttm <= query_obj['to_dttm'])
         status = QueryStatus.SUCCESS
         try:
             df = pd.read_sql_query(qry.statement, db.engine)
diff --git a/superset/viz.py b/superset/viz.py
index c295e5a..e50ee1b 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -379,7 +379,8 @@ class BaseViz(object):
         if query_obj and not is_loaded:
             try:
                 df = self.get_df(query_obj)
-                if hasattr(self.datasource.database, 'db_engine_spec'):
+                if hasattr(self.datasource, 'database') and \
+                        hasattr(self.datasource.database, 'db_engine_spec'):
                     db_engine_spec = self.datasource.database.db_engine_spec
                     df = db_engine_spec.adjust_df_column_names(df, self.form_data)
                 if self.status != utils.QueryStatus.FAILED:


Mime
View raw message