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: raise unexpected error when orderby is empty #15353

Merged
merged 2 commits into from Jun 30, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions superset/charts/schemas.py
Expand Up @@ -1007,11 +1007,21 @@ class Meta: # pylint: disable=too-few-public-methods
allow_none=True,
)
orderby = fields.List(
fields.List(fields.Raw()),
fields.Tuple(
(
fields.Raw(
validate=[
Length(min=1, error=_("orderby column must be populated"))
],
allow_none=False,
),
fields.Boolean(),
)
),
description="Expects a list of lists where the first element is the column "
"name which to sort by, and the second element is a boolean.",
allow_none=True,
example=[["my_col_1", False], ["my_col_2", True]],
example=[("my_col_1", False), ("my_col_2", True)],
)
where = fields.String(
description="WHERE clause to be added to queries using AND operator."
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/query_context.py
Expand Up @@ -31,7 +31,7 @@
},
"groupby": ["name"],
"metrics": [{"label": "sum__num"}],
"orderby": [["sum__num", False]],
"orderby": [("sum__num", False)],
"row_limit": 100,
"granularity": "ds",
"time_range": "100 years ago : now",
Expand Down