From 57ff6123bb9033a94086535c1344518b8cd13cb0 Mon Sep 17 00:00:00 2001 From: "Edgar Y. Walker" Date: Mon, 28 Mar 2016 20:07:39 -0500 Subject: [PATCH 1/5] Fix error where OrderedDict gets mutated during the iteration --- datajoint/base_relation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datajoint/base_relation.py b/datajoint/base_relation.py index 4920307dd..a2834e7ff 100644 --- a/datajoint/base_relation.py +++ b/datajoint/base_relation.py @@ -357,7 +357,7 @@ def delete(self): do_delete = False # indicate if there is anything to delete if config['safemode']: print('The contents of the following tables are about to be deleted:') - for relation in relations.values(): + for relation in list(relations.values()): count = len(relation) if count: do_delete = True From cb6d78f686fbab24aca67978b3992264dec54feb Mon Sep 17 00:00:00 2001 From: "Edgar Y. Walker" Date: Mon, 28 Mar 2016 20:38:10 -0500 Subject: [PATCH 2/5] Introduce back the OrderedDict error with tests to detect that --- datajoint/base_relation.py | 2 +- tests/test_cascading_delete.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/datajoint/base_relation.py b/datajoint/base_relation.py index a2834e7ff..4920307dd 100644 --- a/datajoint/base_relation.py +++ b/datajoint/base_relation.py @@ -357,7 +357,7 @@ def delete(self): do_delete = False # indicate if there is anything to delete if config['safemode']: print('The contents of the following tables are about to be deleted:') - for relation in list(relations.values()): + for relation in relations.values(): count = len(relation) if count: do_delete = True diff --git a/tests/test_cascading_delete.py b/tests/test_cascading_delete.py index fa499ba1e..917748cec 100644 --- a/tests/test_cascading_delete.py +++ b/tests/test_cascading_delete.py @@ -24,6 +24,15 @@ def test_delete_tree(): A().delete() assert_false(A() or B() or B.C() or D() or E() or E.F(), 'incomplete delete') + @staticmethod + def test_stepwise_delete(): + assert_false(dj.config['safemode'], 'safemode must be off for testing') #TODO: just turn it off instead of warning + assert_true(L() and A() and B() and B.C(), 'schema population failed as a precondition to test') + B.C().delete() + assert_false(B.C(), 'failed to delete child tables') + B().delete() + assert_false(B(), 'failed to delete the parent table following child table deletion') + @staticmethod def test_delete_tree_restricted(): assert_false(dj.config['safemode'], 'safemode must be off for testing') From e113a6e6a308ad15498fa05aefe555581ec22df8 Mon Sep 17 00:00:00 2001 From: "Edgar Y. Walker" Date: Mon, 28 Mar 2016 20:38:29 -0500 Subject: [PATCH 3/5] Run TravisCI on Python 3.5 as well --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index c52c11a1d..b48cbc6cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ env: - DJ_TEST_HOST="127.0.0.1" DJ_TEST_USER="root" DJ_TEST_PASSWORD="" DJ_HOST="127.0.0.1" DJ_USER="root" DJ_PASSWORD="" python: - "3.4" + - "3.5" services: mysql install: - pip install -r requirements.txt From 227e37f85cab29baa1115f446394f508df5a861a Mon Sep 17 00:00:00 2001 From: "Edgar Y. Walker" Date: Mon, 28 Mar 2016 20:51:44 -0500 Subject: [PATCH 4/5] Update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 45250c9f6..201c11366 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ dist/ build/ MANIFEST .vagrant/ +dj_local_conf.json From 7d1f66dc726548f2334a475c857ad6cd7c2b4e01 Mon Sep 17 00:00:00 2001 From: "Edgar Y. Walker" Date: Mon, 28 Mar 2016 20:52:24 -0500 Subject: [PATCH 5/5] Fix modification of OrderedDict during iteration --- datajoint/base_relation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datajoint/base_relation.py b/datajoint/base_relation.py index 4920307dd..a2834e7ff 100644 --- a/datajoint/base_relation.py +++ b/datajoint/base_relation.py @@ -357,7 +357,7 @@ def delete(self): do_delete = False # indicate if there is anything to delete if config['safemode']: print('The contents of the following tables are about to be deleted:') - for relation in relations.values(): + for relation in list(relations.values()): count = len(relation) if count: do_delete = True