Skip to content

Commit

Permalink
use transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro committed Jul 1, 2024
1 parent 193b026 commit 028e139
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion superset/key_value/shared_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from superset import db
from superset.key_value.types import JsonKeyValueCodec, KeyValueResource, SharedKey
from superset.key_value.utils import get_uuid_namespace, random_key
from superset.utils.decorators import transaction

RESOURCE = KeyValueResource.APP
NAMESPACE = get_uuid_namespace("")
Expand All @@ -35,13 +36,13 @@ def get_shared_value(key: SharedKey) -> Optional[Any]:
return KeyValueDAO.get_value(RESOURCE, uuid_key, CODEC)

Check warning on line 36 in superset/key_value/shared_entries.py

View check run for this annotation

Codecov / codecov/patch

superset/key_value/shared_entries.py#L36

Added line #L36 was not covered by tests


@transaction()
def set_shared_value(key: SharedKey, value: Any) -> None:
# pylint: disable=import-outside-toplevel
from superset.daos.key_value import KeyValueDAO

Check warning on line 42 in superset/key_value/shared_entries.py

View check run for this annotation

Codecov / codecov/patch

superset/key_value/shared_entries.py#L42

Added line #L42 was not covered by tests

uuid_key = uuid3(NAMESPACE, key)
KeyValueDAO.create_entry(RESOURCE, value, CODEC, uuid_key)

Check warning on line 45 in superset/key_value/shared_entries.py

View check run for this annotation

Codecov / codecov/patch

superset/key_value/shared_entries.py#L45

Added line #L45 was not covered by tests
db.session.commit() # pylint: disable=consider-using-transaction


def get_permalink_salt(key: SharedKey) -> str:
Expand Down

0 comments on commit 028e139

Please sign in to comment.