Created two separate actions under variable to delete/unset.

`delete` will actually remove the record from the database (same as
`unset`'s new behaviour), while `unset` will set it to null without
deleting it (same as the `unset`'s previous behaviour).
This commit is contained in:
Fabio Manganiello 2023-05-05 02:21:18 +02:00
parent 98b9d31dd4
commit 373788377b
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -57,9 +57,12 @@ class VariablePlugin(Plugin, EntityManager):
return kwargs
@action
def unset(self, name: str):
def delete(self, name: str):
"""
Unset a variable by name if it's set on the local db.
Delete a variable from the database.
Unlike :meth:`.unset`, this method actually deletes the record from the
database instead of setting it to null.
:param name: Name of the variable to remove.
"""
@ -72,6 +75,19 @@ class VariablePlugin(Plugin, EntityManager):
self._db_vars.pop(name, None)
return True
@action
def unset(self, name: str):
"""
Unset a variable by name if it's set on the local db.
Unlike :meth:`.delete`, this method only sets the record to null
instead of removing it from the database.
:param name: Name of the variable to remove.
"""
return self.set(**{name: None})
@action
def mget(self, name: str):
"""