#3615: Can't define forward references in fixtures using MySQL with InnoDB
---------------------------------------------------+------------------------
          Reporter:  russellm                      |         Owner:  nobody     
                          
            Status:  new                           |     Milestone:             
                          
         Component:  Database layer (models, ORM)  |       Version:  SVN        
                          
        Resolution:                                |      Keywords:  mysql 
innodb myisam reference fixture
             Stage:  Accepted                      |     Has_patch:  0          
                          
        Needs_docs:  0                             |   Needs_tests:  0          
                          
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Comment (by ramiro):

 Replying to [comment:9 kmtracey]:
 > As it is it isn't clear to me if this approach really helps at all for
 MS SQL Server, since it apparently wants table names on which to turn off
 constraint checking, but maybe someone who knows more (Ramiro?) on that
 topic can comment...)

 You are right, implementing this in SQL server doesn't imply controlling
 things  by toggling a global variable but by ALTERing TABLE so the names
 of the tables are needed.

 So far, I've solved this by cloning the `loaddata` management command and
 modifying the copy to insert calls to the two new methods in the same way
 it's done in the patches we  have posted. But they mostly only serve to
 mark the boundaries of a period of time in which insertions of forward
 references are possible. Real work is done in a hook that is a no-op
 except when running during one of such periods, it's called every time
 fixtures for a model are going to be loaded, in these edges the model is
 introspected in search of outgoing FKs and M2M, if there are any the
 corresponding ALTER TABLEs are performed.

 http://code.google.com/p/django-
 
pyodbc/source/browse/trunk/sql_server/extra/management/commands/ss_loaddata.py#165

 (Currently all the constraint checks for a given table are deactivated,
 but it can be made more fine grained and to have the less overall impact
 possible in the DB by even introspecting the names of the constraints and
 only deactivating these. This is in my TODO list)

 So, I think a backend for SQL Server could make use of the
 begin_defer_constraint_checks()/end_defer_constraint_checks() methods but
 when it comes to table names, being able to do thing in a way as granular
 as possible (by no touching tables that aren't involved) would need an
 additional hook (similar to the one I created) being provided in some way.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/3615#comment:11>
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