Skip to content

Commit c289190

Browse files
authored
Revert "Add support to remove the key of table entry (#15)" (#24)
This reverts commit 993d961.
1 parent 993d961 commit c289190

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/swsssdk/configdb.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,17 @@ def __raw_to_typed(self, raw_data):
115115

116116
def __typed_to_raw(self, typed_data):
117117
if typed_data == None:
118-
return None, None
118+
return None
119119
elif typed_data == {}:
120-
return { "NULL": "NULL" }, None
120+
return { "NULL": "NULL" }
121121
raw_data = {}
122-
del_data = []
123122
for key in typed_data:
124123
value = typed_data[key]
125124
if type(value) is list:
126125
raw_data[key+'@'] = ','.join(value)
127-
elif value is None:
128-
del_data.append(key)
129126
else:
130127
raw_data[key] = value
131-
return raw_data, del_data
128+
return raw_data
132129

133130
@staticmethod
134131
def serialize_key(key):
@@ -153,19 +150,14 @@ def set_entry(self, table, key, data):
153150
data: Table row data in a form of dictionary {'column_key': 'value', ...}.
154151
Pass {} as data will create an entry with no column if not already existed.
155152
Pass None as data will delete the entry.
156-
Pass {'column_key': None, ...} as data will delete the key which value is None.
157153
"""
158154
key = self.serialize_key(key)
159155
client = self.redis_clients[self.CONFIG_DB]
160156
_hash = '{}{}{}'.format(table.upper(), self.TABLE_NAME_SEPARATOR, key)
161157
if data == None:
162158
client.delete(_hash)
163159
else:
164-
raw_data, del_data = self.__typed_to_raw(data)
165-
if del_data:
166-
client.hdel(_hash, *del_data)
167-
if raw_data:
168-
client.hmset(_hash, raw_data)
160+
client.hmset(_hash, self.__typed_to_raw(data))
169161

170162
def get_entry(self, table, key):
171163
"""Read a table entry from config db.

0 commit comments

Comments
 (0)