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

[cccs-2.0] Fixing case sensitivity #203

Merged
merged 18 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
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 @@ -302,21 +302,40 @@ 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')) {
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;
if (dataset.main_dttm_col !== null) {
if (dataset.main_dttm_col) {
props.default = dataset.main_dttm_col;
} else if (props?.options.length > 0) {
props.default = (props.options[0] as ColumnMeta).column_name;
}
} else {
const sortedQueryColumns = (datasource as QueryResponse)?.columns
?.filter(query => query?.is_dttm === true)
.sort();
props.options = sortedQueryColumns;
if (props?.options.length > 0) {
props.default =
'column_name' in props.options[0]
? props.options[0]?.column_name
: props.options[0]?.name;
}
}
} else {
const sortedQueryColumns = (datasource as QueryResponse)?.columns?.sort(
query => (query?.is_dttm ? -1 : 1),
);
const sortedQueryColumns = (datasource as QueryResponse)?.columns
?.filter(query => query?.is_dttm === true)
.sort();
props.options = sortedQueryColumns;
if (props?.options) props.default = props.options[0]?.name;
if (props?.options.length > 0) {
props.default =
'column_name' in props.options[0]
? props.options[0]?.column_name
: props.options[0]?.name;
}
}
return props;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,6 @@ const defineSavedMetrics = (
? (datasource as Dataset)?.metrics || []
: DEFAULT_METRICS;

const columnChoices = (datasource: any) => {
if (datasource?.columns) {
return datasource.columns
.map((col : any) => [col.column_name, col.verbose_name || col.column_name])
.sort((opt1: any, opt2: any) =>
opt1[1].toLowerCase() > opt2[1].toLowerCase() ? 1 : -1,
);
}
return [];
}

const config: ControlPanelConfig = {
// For control input types, see: superset-frontend/src/explore/components/controls/index.js
controlPanelSections: [
Expand Down Expand Up @@ -368,22 +357,6 @@ const config: ControlPanelConfig = {
},
},
],
[
{
name: 'order_by_cols',
config: {
type: 'SelectControl',
label: t('Ordering'),
description: t('Order results by selected columns'),
multi: true,
default: [],
mapStateToProps: ({ datasource }) => ({
choices: columnChoices(datasource),
}),
visibility: isRawMode,
},
},
],
[
{
name: 'timeseries_limit_metric',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ const ExploreChartPanel = ({
css={css`
min-height: 0;
flex: 1;
overflow: auto;
overflow: hidden;
`}
ref={chartPanelRef}
>
Expand Down
2 changes: 1 addition & 1 deletion superset/advanced_data_type/plugins/internet_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def port_translate_filter_func(


internet_port: AdvancedDataType = AdvancedDataType(
verbose_name="port",
verbose_name="Port",
description="represents of a port",
valid_data_types=["int"],
translate_filter=port_translate_filter_func,
Expand Down
2 changes: 1 addition & 1 deletion superset/connectors/sqla/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,7 @@ def get_sqla_query( # pylint: disable=too-many-arguments,too-many-locals,too-ma
)

col_advanced_data_type: str = col_obj.advanced_data_type if col_obj else ""

col_advanced_data_type = col_advanced_data_type.lower() if col_advanced_data_type else col_advanced_data_type
if col_spec and not col_advanced_data_type:
target_generic_type = col_spec.generic_type
else:
Expand Down