From 373788377bbab1e3e6bed6bc23728b55ab51a07b Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Fri, 5 May 2023 02:21:18 +0200 Subject: [PATCH] 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). --- platypush/plugins/variable/__init__.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/platypush/plugins/variable/__init__.py b/platypush/plugins/variable/__init__.py index f40cc09f7..85520f70d 100644 --- a/platypush/plugins/variable/__init__.py +++ b/platypush/plugins/variable/__init__.py @@ -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): """