Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Ensure main_dttm_col is adhered to for non-drag-and-drop #20712

Merged
merged 1 commit into from
Jul 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,14 @@ const granularity_sqla: SharedControlConfig<'SelectControl', ColumnMeta> = {
mapStateToProps: state => {
const props: Partial<SelectControlConfig<ColumnMeta | QueryColumn>> = {};
const { datasource } = state;
if (datasource?.columns[0]?.hasOwnProperty('main_dttm_col')) {
if (datasource?.hasOwnProperty('main_dttm_col')) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main_dttm_col property exists on the datasource object as opposed the associated columns.

const dataset = datasource as Dataset;
props.options = dataset.columns.filter((c: ColumnMeta) => c.is_dttm);
props.default = null;
if (dataset.main_dttm_col) {
props.default = dataset.main_dttm_col;
} else if (props?.options) {
props.default = (props.options[0] as ColumnMeta).column_name;
props.default = (props.options[0] as ColumnMeta)?.column_name;
}
} else {
const sortedQueryColumns = (datasource as QueryResponse)?.columns?.sort(
Expand Down