some foreign keys get set to NULL

Issue #478 resolved
Former user created an issue

(original reporter: Justin) I'll attatch the test files

Comments (9)

  1. Former user Account Deleted

    (original author: Justin) I am very confused now. I was able to remove almost everything and it still fails. I was almost certain it was a problem with my code, but there is not much left now.

    The interesting thing is that now it either fails on moving the very first jack, or it successfuly moves half the jacks:

    (%:~/tmp/sa_bug)- ./test.py
    adding 1-100A
    adding 1-101A
    adding 1-102A
    adding 1-103A
    adding 1-104A
    adding 1-105A
    adding 1-106A
    adding 1-107A
    adding 1-108A
    adding 1-109A
    Moving {Jack 9791 - 1-100A} to {Room 1626 - 102}
    Traceback (most recent call last):
    ...
    sqlalchemy.exceptions.SQLError: (IntegrityError) ERROR:  null value in column "room_id" violates not-null constraint  UPDATE jack SET room_id=NULL WHERE jack.id = 9791 'UPDATE jack SET room_id=%(room_id)s WHERE jack.id = %(jack_id)s' {'room_id': None, 'jack_id': 9791}
    
    (%:~/tmp/sa_bug)- ./test.py
    adding 1-100A
    adding 1-101A
    adding 1-102A
    adding 1-103A
    adding 1-104A
    adding 1-105A
    adding 1-106A
    adding 1-107A
    adding 1-108A
    adding 1-109A
    Moving {Jack 9731 - 1-100A} to {Room 1614 - 102}
    Moving {Jack 9733 - 1-102A} to {Room 1614 - 102}
    Moving {Jack 9735 - 1-104A} to {Room 1614 - 102}
    Moving {Jack 9737 - 1-106A} to {Room 1614 - 102}
    Moving {Jack 9739 - 1-108A} to {Room 1614 - 102}
    

    Where did jacks 101,103,105,107,109 go? If I enable echo I can see them being inserted.

  2. Mike Bayer repo owner

    the fix:

        def test_move(self):
            moved = 0
            for j in list(self.ec052c6a1f1fb0236bd367c510d82f076cb67bc9.jacks):
                print "Moving %s to %s" % (j, self.76ed6f7ab6823d0906286026a40e6a3fca7ada27)
                j.change_room(self.76ed6f7ab6823d0906286026a40e6a3fca7ada27)
                moved +=1
    
            assert moved == self.total
    

    do you see why ?

  3. Log in to comment