From commits-return-1304-archive-asf-public=cust-asf.ponee.io@superset.incubator.apache.org Mon Aug 13 22:55:01 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 5EF2F180629 for ; Mon, 13 Aug 2018 22:55:01 +0200 (CEST) Received: (qmail 92164 invoked by uid 500); 13 Aug 2018 20:55:00 -0000 Mailing-List: contact commits-help@superset.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@superset.incubator.apache.org Delivered-To: mailing list commits@superset.incubator.apache.org Received: (qmail 92155 invoked by uid 99); 13 Aug 2018 20:55:00 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Aug 2018 20:55:00 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 0092C81E15; Mon, 13 Aug 2018 20:54:59 +0000 (UTC) Date: Mon, 13 Aug 2018 20:54:59 +0000 To: "commits@superset.apache.org" Subject: [incubator-superset] branch master updated: [fix] Enforcing main dttm column (#5584) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <153419369977.11792.11011821382068229836@gitbox.apache.org> From: johnbodley@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: incubator-superset X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 50981dbc698bb88055ccf5aa575e958704b8d372 X-Git-Newrev: 2685ab4f1f16100ce0bf365c10a63ced258d37a7 X-Git-Rev: 2685ab4f1f16100ce0bf365c10a63ced258d37a7 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. johnbodley 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 2685ab4 [fix] Enforcing main dttm column (#5584) 2685ab4 is described below commit 2685ab4f1f16100ce0bf365c10a63ced258d37a7 Author: John Bodley <4567245+john-bodley@users.noreply.github.com> AuthorDate: Mon Aug 13 13:54:55 2018 -0700 [fix] Enforcing main dttm column (#5584) --- superset/assets/src/explore/controls.jsx | 19 ++++++++++--------- superset/connectors/sqla/models.py | 1 + 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/superset/assets/src/explore/controls.jsx b/superset/assets/src/explore/controls.jsx index ddf0775..50fe3bf 100644 --- a/superset/assets/src/explore/controls.jsx +++ b/superset/assets/src/explore/controls.jsx @@ -832,22 +832,23 @@ export const controls = { 'column in the table. Also note that the ' + 'filter below is applied against this column or ' + 'expression'), - default: (c) => { - if (c.options && c.options.length > 0) { - return c.options[0].column_name; - } - return null; - }, + default: control => control.default, clearable: false, optionRenderer: c => , valueRenderer: c => , valueKey: 'column_name', mapStateToProps: (state) => { - const newState = {}; + const props = {}; if (state.datasource) { - newState.options = state.datasource.columns.filter(c => c.is_dttm); + props.options = state.datasource.columns.filter(c => c.is_dttm); + props.default = null; + if (state.datasource.main_dttm_col) { + props.default = state.datasource.main_dttm_col; + } else if (props.options && props.options.length > 0) { + props.default = props.options[0].column_name; + } } - return newState; + return props; }, }, diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py index e654926..61483cc 100644 --- a/superset/connectors/sqla/models.py +++ b/superset/connectors/sqla/models.py @@ -410,6 +410,7 @@ class SqlaTable(Model, BaseDatasource): grains = [(g.duration, g.name) for g in grains] d['granularity_sqla'] = utils.choicify(self.dttm_cols) d['time_grain_sqla'] = grains + d['main_dttm_col'] = self.main_dttm_col return d def values_for_column(self, column_name, limit=10000):