#15068: initial_data fixtures using natural keys fail in tests with multiple
databases
----------------------------------------+-----------------------------------
          Reporter:  dcramer            |         Owner:  nobody
            Status:  closed             |     Milestone:        
         Component:  Testing framework  |       Version:  1.2   
        Resolution:  invalid            |      Keywords:        
             Stage:  Accepted           |     Has_patch:  0     
        Needs_docs:  0                  |   Needs_tests:  0     
Needs_better_patch:  0                  |  
----------------------------------------+-----------------------------------
Comment (by dcramer):

 Natural keys require the data to exist in the database before they're
 referenced. With the way fixtures work, they're instantiated before
 running the "allow_syncdb" check. In our case, a database with the name
 "analytics" was loaded before "default", which contains very few tables.
 When it gets around to a fixture with a natural key, it attempts to
 instantiate it using the natural key code path, which attempts to validate
 a foreign key against a table that does not exist. I'm pretty certain this
 is valid, and while it may be an edge case (not sure how common natural
 key usage is), it's certainly very odd behavior.

 I attempted to shift loading fixtures after syncdb was done (on every
 database), but that still doesnt solve it, as the fixtures load per
 database (not globally), and in this case, they still have the same issue.
 I think the proper fix would be to change natural keys so they're mapped
 in memory, but that requires quite a large change to Django itself I
 imagine, as last I knew relationships dont support associations if they
 dont have an identifier, which these wouldn't.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15068#comment:3>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to