fixed uniqueness problem in archives

This commit is contained in:
mdipierro
2012-07-17 10:59:26 -05:00
parent ac75bbdc9c
commit f3ea2d1cc6
3 changed files with 16 additions and 9 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.00.0 (2012-07-17 10:35:39) dev
Version 2.00.0 (2012-07-17 10:59:23) dev
+11 -5
View File
@@ -7130,10 +7130,8 @@ class Table(dict):
table = field
for field in table:
if not field.name in fieldnames and not field.type=='id':
field = copy.copy(field)
# correct self references
if not table._actual and field.type == 'reference '+table._tablename:
field.type = 'reference '+self._tablename
t2 = not table._actual and self._tablename
field = field.clone(point_self_references_to=t2)
newfields.append(field)
fieldnames.add(field.name)
else:
@@ -7210,7 +7208,7 @@ class Table(dict):
archive_table = archive_db.define_table(
archive_name,
Field(current_record,field_type),
self)
*[field.close(unique=False) for field in self])
self._before_update.append(
lambda qset,fs,at=archive_table,cn=current_record:
archive_record(qset,fs,at,cn))
@@ -8038,6 +8036,14 @@ class Field(Expression):
else:
self.requires = requires
def clone(self,point_self_references_to=False,**args):
field = copy.copy(self)
if point_self_references_to and \
field.type == 'reference %s'+field._tablename:
field.type = 'reference %s' % point_self_references_to
field.__dict__.update(args)
return field
def store(self, file, filename=None, path=None):
if self.custom_store:
return self.custom_store(file,filename,path)
+4 -3
View File
@@ -3029,9 +3029,10 @@ class Auth(object):
if archive_table_name in table._db:
archive_table = table._db[archive_table_name]
else:
archive_table = table._db.define_table(archive_table_name,
Field(current_record,table),
table)
archive_table = table._db.define_table(
archive_table_name,
Field(current_record,table),
*[field.close(unique=False) for field in table])
new_record = {current_record:form.vars.id}
for fieldname in archive_table.fields:
if not fieldname in ['id',current_record]: