mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
feat: return UUID on database creation (#23143)
This commit is contained in:
@@ -48,6 +48,7 @@ export type DatabaseObject = {
|
||||
engine?: string;
|
||||
extra?: string;
|
||||
id?: number;
|
||||
uuid?: null | string;
|
||||
name: string; // synonym to database_name
|
||||
paramProperties?: Record<string, any>;
|
||||
sqlalchemy_uri?: string;
|
||||
|
||||
@@ -325,6 +325,7 @@ class DatabaseRestApi(BaseSupersetModelRestApi):
|
||||
return self.response_400(message=error.messages)
|
||||
try:
|
||||
new_model = CreateDatabaseCommand(item).run()
|
||||
item["uuid"] = new_model.uuid
|
||||
# Return censored version for sqlalchemy URI
|
||||
item["sqlalchemy_uri"] = new_model.sqlalchemy_uri
|
||||
item["expose_in_sqllab"] = new_model.expose_in_sqllab
|
||||
|
||||
@@ -479,6 +479,7 @@ class DatabasePutSchema(Schema, DatabaseParametersSchemaMixin):
|
||||
is_managed_externally = fields.Boolean(allow_none=True, default=False)
|
||||
external_url = fields.String(allow_none=True)
|
||||
ssh_tunnel = fields.Nested(DatabaseSSHTunnel, allow_none=True)
|
||||
uuid = fields.String(required=False)
|
||||
|
||||
|
||||
class DatabaseTestConnectionSchema(Schema, DatabaseParametersSchemaMixin):
|
||||
|
||||
@@ -50,6 +50,10 @@ def test_post_with_uuid(
|
||||
)
|
||||
assert response.status_code == 201
|
||||
|
||||
# check that response includes UUID
|
||||
payload = response.json
|
||||
assert payload["result"]["uuid"] == "7c1b7880-a59d-47cd-8bf1-f1eb8d2863cb"
|
||||
|
||||
database = session.query(Database).one()
|
||||
assert database.uuid == UUID("7c1b7880-a59d-47cd-8bf1-f1eb8d2863cb")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user