I propose this patch
Le vendredi 12 juillet 2013 14:08:21 UTC+2, Olivier Johner a écrit :
>
> It's ok for the foreign key but when you archive records in another
> database, all fields comes in "big int" and raise a value error for string
> fields
>
> ValueError: invalid literal for long() with base 10: 'v6 box spearmint'
>
>
> Le dimanche 16 juin 2013 10:28:26 UTC+2, Massimo Di Pierro a écrit :
>>
>> This should now be fixed in trunk. Please check it.
>>
>> On Thursday, 6 June 2013 08:19:35 UTC-5, Lamps902 wrote:
>>>
>>> To clarify, due to the SQL Foreign Key constraint (which is retained
>>> when archive tables are created through auth.enable_record_versioning),
>>> some of the archive database's tables still retain an association with the
>>> auth_user table's id field. However, the rows with the ids on which the new
>>> tables depend may not necessarily be transferred from the application's
>>> primary database to the archive database. Is there a way to use the DAL to
>>> remove the Foreign Key constraint? Thanks.
>>>
>>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
diff --git a/gluon/dal.py b/gluon/dal.py
index af20494..7671cd7 100644
--- a/gluon/dal.py
+++ b/gluon/dal.py
@@ -8307,8 +8307,11 @@ class Table(object):
field_type = self if same_db else 'bigint'
clones = []
for field in self:
+ fk = False
+ if field.type.find('reference') != -1:
+ fk = True if not same_db else False
clones.append(field.clone(
- unique=False, type=field.type if same_db else 'bigint'))
+ unique=False, type=field.type if (same_db or not fk) else
'bigint'))
archive_db.define_table(
archive_name, Field(current_record,field_type), *clones)
self._before_update.append(