fix: raise unexpected error when orderby is empty (#15353)

* fix: raise unexpected error when orderby is empty

* fix ut
This commit is contained in:
Yongjie Zhao 2021-06-30 12:34:54 +01:00 committed by GitHub
parent ebb3efce5a
commit 292bce5862
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -1007,11 +1007,21 @@ class ChartDataQueryObjectSchema(Schema):
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."

View File

@ -31,7 +31,7 @@ query_birth_names = {
},
"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",