Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ dist/
build/
MANIFEST
.vagrant/
dj_local_conf.json
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion datajoint/base_relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions tests/test_cascading_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down