This is an automated email from the ASF dual-hosted git repository.
villebro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 8375baac99 fix(dataset-api): allow undefined schema in post (#24242)
8375baac99 is described below
commit 8375baac99a3267f46807da15b997094eb3ddba2
Author: Ville Brofeldt <[email protected]>
AuthorDate: Tue May 30 17:48:54 2023 +0300
fix(dataset-api): allow undefined schema in post (#24242)
---
superset/datasets/schemas.py | 6 ++++--
tests/integration_tests/datasets/api_tests.py | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/superset/datasets/schemas.py b/superset/datasets/schemas.py
index 2d471781e0..f248fc70ff 100644
--- a/superset/datasets/schemas.py
+++ b/superset/datasets/schemas.py
@@ -78,7 +78,7 @@ class DatasetMetricsPutSchema(Schema):
class DatasetPostSchema(Schema):
database = fields.Integer(required=True)
- schema = fields.String(validate=Length(0, 250))
+ schema = fields.String(allow_none=True, validate=Length(0, 250))
table_name = fields.String(required=True, allow_none=False,
validate=Length(1, 250))
sql = fields.String(allow_none=True)
owners = fields.List(fields.Integer())
@@ -236,7 +236,9 @@ class GetOrCreateDatasetSchema(Schema):
required=True, metadata={"description": "ID of database table belongs
to"}
)
schema = fields.String(
- metadata={"description": "The schema the table belongs to"},
allow_none=True
+ allow_none=True,
+ validate=Length(0, 250),
+ metadata={"description": "The schema the table belongs to"},
)
template_params = fields.String(
metadata={"description": "Template params for the table"}
diff --git a/tests/integration_tests/datasets/api_tests.py
b/tests/integration_tests/datasets/api_tests.py
index f87bafcd37..2c358d7114 100644
--- a/tests/integration_tests/datasets/api_tests.py
+++ b/tests/integration_tests/datasets/api_tests.py
@@ -530,7 +530,7 @@ class TestDatasetApi(SupersetTestCase):
self.login(username="admin")
table_data = {
"database": main_db.id,
- "schema": "",
+ "schema": None,
"table_name": "ab_permission",
}
uri = "api/v1/dataset/"