Skip to content

Commit

Permalink
Merge pull request #18 from thingsdb/rename
Browse files Browse the repository at this point in the history
Added handlers for rename functions, issue #17
  • Loading branch information
Jeroen van der Heijden authored Sep 4, 2020
2 parents 315498e + d0a4104 commit 22c1b98
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
9 changes: 9 additions & 0 deletions thingsdb/model/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ def _set_procedure(self, data):
name,
scope=self._scope))

def _rename_procedure(self, data):
old = data['old']
name = data['name']
func = getattr(self, old, None)
if callable(func):
setattr(self, name, func)
delattr(self, old)

def _update_type(self, data):
self._types[data['type_id']] = tuple(k[0] for k in data['fields'])

Expand Down Expand Up @@ -188,6 +196,7 @@ def _upd_enum_mod(self, data):
Enum._upd_enum_mod(self._enums, data, self._conv_any)

def _upd_enum_ren(self, data):
'''Rename a enum member.'''
Enum._upd_enum_ren(self._enums, data)

def _get_enum_member(self, enum_id, idx):
Expand Down
14 changes: 14 additions & 0 deletions thingsdb/model/thing.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,17 @@ def _job_new_type(self, data):
data['fields'] = []
self._collection._update_type(data)

def _job_rename_enum(self, data):
# rename a enum type
pass

def _job_rename_procedure(self, data):
self._collection._rename_procedure(data)

def _job_rename_type(self, data):
# we do not rename a type in python
pass

def _job_set_type(self, data):
self._collection._update_type(data)

Expand Down Expand Up @@ -327,6 +338,9 @@ def _job_set_type(self, data):
'mod_enum_ren': _job_mod_enum_ren,
'new_procedure': _job_new_procedure,
'new_type': _job_new_type,
'rename_enum': _job_rename_enum,
'rename_procedure': _job_rename_procedure,
'rename_type': _job_rename_type,
'set_type': _job_set_type,
}

Expand Down
2 changes: 1 addition & 1 deletion thingsdb/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.6.13'
__version__ = '0.6.14'

0 comments on commit 22c1b98

Please sign in to comment.