mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
chore(key-value): convert command to dao (#29344)
This commit is contained in:
@@ -20,8 +20,9 @@ from typing import Any, Optional
|
||||
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
|
||||
from superset import db
|
||||
from superset.commands.explore.permalink.base import BaseExplorePermalinkCommand
|
||||
from superset.commands.key_value.create import CreateKeyValueCommand
|
||||
from superset.daos.key_value import KeyValueDAO
|
||||
from superset.explore.permalink.exceptions import ExplorePermalinkCreateFailedError
|
||||
from superset.explore.utils import check_access as check_chart_access
|
||||
from superset.key_value.exceptions import (
|
||||
@@ -65,15 +66,12 @@ class CreateExplorePermalinkCommand(BaseExplorePermalinkCommand):
|
||||
"datasource": self.datasource,
|
||||
"state": self.state,
|
||||
}
|
||||
command = CreateKeyValueCommand(
|
||||
resource=self.resource,
|
||||
value=value,
|
||||
codec=self.codec,
|
||||
)
|
||||
key = command.run()
|
||||
if key.id is None:
|
||||
entry = KeyValueDAO.create_entry(self.resource, value, self.codec)
|
||||
db.session.flush()
|
||||
key = entry.id
|
||||
if key is None:
|
||||
raise ExplorePermalinkCreateFailedError("Unexpected missing key id")
|
||||
return encode_permalink_key(key=key.id, salt=self.salt)
|
||||
return encode_permalink_key(key=key, salt=self.salt)
|
||||
|
||||
def validate(self) -> None:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user