Commit cc4bd91b authored by Vincent Pelletier's avatar Vincent Pelletier

Fix a problem of duplicate Id generation when the SQL table gets flushed...

Fix a problem of duplicate Id generation when the SQL table gets flushed (happens during a clear catalog).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14043 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4b78b960
......@@ -192,6 +192,11 @@ class IdTool(UniqueObject, Folder):
id_group = repr(id_group)
if not isinstance(default, int):
default = 1
if self.dict_length_ids.get(id_group) is None:
self.dict_length_ids[id_group] = Length()
# If the table has been flushed, the latest stored id must be used if
# it's greater than the default value.
default = max(default, self.dict_length_ids[id_group]())
# FIXME: A skin folder should be used to contain ZSQLMethods instead of
# default catalog, like activity tool (anyway, it uses activity tool
# ZSQLConnection, so hot reindexing is not helping here).
......@@ -207,8 +212,6 @@ class IdTool(UniqueObject, Folder):
finally:
commit()
new_id = result[0]['LAST_INSERT_ID()']
if self.dict_length_ids.get(id_group) is None:
self.dict_length_ids[id_group] = Length(new_id)
self.dict_length_ids[id_group].set(new_id)
return range(new_id - id_count, new_id)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment