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: gsheets editing with dynamic forms #21710

Merged
merged 9 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions superset/databases/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@ class Meta: # pylint: disable=too-few-public-methods
values=fields.Raw(allow_none=True),
description="DB-specific parameters for configuration",
)
catalog = fields.List(
fields.Dict(
keys=fields.String(),
values=fields.Raw(allow_none=True),
description="Gsheets specific column for managing label to sheet urls",
)
)
database_name = fields.String(
description=database_name_description,
allow_none=True,
Expand Down
10 changes: 8 additions & 2 deletions superset/db_engine_specs/gsheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,22 @@ def validate_parameters(
properties: GSheetsPropertiesType,
) -> List[SupersetError]:
errors: List[SupersetError] = []

# backwards compatible just incase people are send data
# via parameters for validation
parameters = properties.get("parameters", {})
if parameters:
table_catalog = parameters.get("catalog", {})
else:
table_catalog = properties.get("catalog", {})

encrypted_credentials = parameters.get("service_account_info") or "{}"

# On create the encrypted credentials are a string,
# at all other times they are a dict
if isinstance(encrypted_credentials, str):
encrypted_credentials = json.loads(encrypted_credentials)

table_catalog = parameters.get("catalog", {})

if not table_catalog:
# Allowing users to submit empty catalogs
errors.append(
Expand Down