Idl.__parse_row_update() assumed that every change that the database server
sent down actually modified the database. This is generally true, but
since Idl.__modify_row() already returns whether there was a change, we
might as well use it.
Reported-by: Reid Price <reid@nicira.com>
def __parse_row_update(self, table, uuid, old, new):
"""Returns True if a column changed, False otherwise."""
row = self.data[table.name].get(uuid)
def __parse_row_update(self, table, uuid, old, new):
"""Returns True if a column changed, False otherwise."""
row = self.data[table.name].get(uuid)
if not new:
# Delete row.
if row:
del self.data[table.name][uuid]
if not new:
# Delete row.
if row:
del self.data[table.name][uuid]
else:
# XXX rate-limit
logging.warning("cannot delete missing row %s from table %s"
% (uuid, table.name))
else:
# XXX rate-limit
logging.warning("cannot delete missing row %s from table %s"
% (uuid, table.name))
elif not old:
# Insert row.
if not row:
row = self.__create_row(table, uuid)
elif not old:
# Insert row.
if not row:
row = self.__create_row(table, uuid)
else:
# XXX rate-limit
logging.warning("cannot add existing row %s to table %s"
% (uuid, table.name))
else:
# XXX rate-limit
logging.warning("cannot add existing row %s to table %s"
% (uuid, table.name))
- self.__modify_row(table, row, new)
+ if self.__modify_row(table, row, new):
+ changed = True
else:
if not row:
row = self.__create_row(table, uuid)
else:
if not row:
row = self.__create_row(table, uuid)
# XXX rate-limit
logging.warning("cannot modify missing row %s in table %s"
% (uuid, table_name))
# XXX rate-limit
logging.warning("cannot modify missing row %s in table %s"
% (uuid, table_name))
- self.__modify_row(table, row, new)
- return True
+ if self.__modify_row(table, row, new):
+ changed = True
+ return changed
def __modify_row(self, table, row, row_json):
changed = False
def __modify_row(self, table, row, row_json):
changed = False