Incorrect archive/restore behavior?

106 views
Skip to first unread message

jimka...@yahoo.com

unread,
Jan 17, 2024, 3:59:59 PMJan 17
to web2py-users
Hi,

I believe (using python 3.11.7, web2py 2,24,1, mysql 8),
with web2py record versioning enabled,
 I have verified that 

          db.export_to_csv_file does not write table rows that have the "is_active" field set
         to False.

A simple test case is 
    1. add a new (is_active=True) row to a table (e.g. mediatitles), 
        This results in an "is_active = True" row in mediatitles, 
    2.  Delete (archive) it.
          This results in an "is_active = False" row in mediatitles, 
          and creation of an "is_active = True" row in table mediatitles_archive

    3. Now, backup the db (db.export...)
    4. restore it (db.import_from_csv_file)

Having cleared out the tables before step 3, this results in an empty mediatitles table and  a mediatitles_archive table with one row

which, during execution, causes a MYSQL exception:

"(1452, 'Cannot add or update a child row: 
a foreign key constraint fails (`mfm_curr_lib`.`mediatitles_archive`, CONSTRAINT `mediatitles_archive_ibfk_1` FOREIGN KEY (`current_record`) REFERENCES `mediatitles` (`id`) ON DELETE CASCADE)') 

since there is no row in mediatitles that mediatitles_archive can reference.

Am I doing something wrong?
Is this fixed in a later web2py version?

Thanks



jimka...@yahoo.com

unread,
Jan 17, 2024, 6:28:37 PMJan 17
to web2py-users
Sorry, 

for "Having cleared out the tables before step 3, this results"  this should have said step 4

for "since there is no row in mediatitles that mediatitles_archive..."  this should have said there is no row in mediatitles with the required id 

jimka...@yahoo.com

unread,
Apr 11, 2024, 7:52:37 PMApr 11
to web2py-users
I've been working on this for a while now off and on and have, I believe, fixed the web2py gluon code bugs to correct this problem. I filed my fix here - https://github.com/web2py/web2py/issues/2483
Reply all
Reply to author
Forward
0 new messages