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: Errors when saving dataset #24113

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 @@ -150,7 +150,7 @@ const DatasourceModal: FunctionComponent<DatasourceModalProps> = ({
groupby: column.groupby,
is_active: column.is_active,
is_dttm: column.is_dttm,
python_date_format: column.python_date_format,
python_date_format: column.python_date_format || null,
Copy link
Member Author

Choose a reason for hiding this comment

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

Allows for the field to be cleared, before an empty string was failing a Length(1, 255) validation

uuid: column.uuid,
extra: buildExtraJsonObject(column),
}),
Expand Down
6 changes: 3 additions & 3 deletions superset/datasets/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ def validate_python_date_format(value: str) -> None:
r"""
^(
epoch_s|epoch_ms|
(?P<date>%Y(-%m(-%d)?)?)([\sT](?P<time>%H(:%M(:%S(\.%f)?)?)?))?
(?P<date>%Y([-/]%m([-/]%d)?)?)([\sT](?P<time>%H(:%M(:%S(\.%f)?)?)?))?
)$
""",
re.VERBOSE,
)
match = regex.match(value or "")
if not match:
raise ValidationError(_("Invalid date/timestamp format"))
raise ValidationError([_("Invalid date/timestamp format")])
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 API error response was malformed without this, was giving ["I", "n", "v", ...]. This fixes it



class DatasetColumnsPutSchema(Schema):
Expand All @@ -56,7 +56,7 @@ class DatasetColumnsPutSchema(Schema):
filterable = fields.Boolean()
groupby = fields.Boolean()
is_active = fields.Boolean(allow_none=True)
is_dttm = fields.Boolean(dump_default=False)
is_dttm = fields.Boolean(allow_none=True, dump_default=False)
Copy link
Member Author

Choose a reason for hiding this comment

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

Columns can have is_dttm being null, this allows datasets with such columns to be updated without error

python_date_format = fields.String(
allow_none=True, validate=[Length(1, 255), validate_python_date_format]
)
Expand Down
Loading