#14849: ManyToManyField has weird behavior in 1.2 w/ multi-db
---------------------------------------------------+------------------------
          Reporter:  joestump                      |         Owner:  nobody
            Status:  closed                        |     Milestone:        
         Component:  Database layer (models, ORM)  |       Version:  1.2   
        Resolution:  worksforme                    |      Keywords:        
             Stage:  Unreviewed                    |     Has_patch:  0     
        Needs_docs:  0                             |   Needs_tests:  0     
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Changes (by russellm):

  * status:  new => closed
  * needs_better_patch:  => 0
  * resolution:  => worksforme
  * needs_tests:  => 0
  * needs_docs:  => 0

Comment:

 There's something important missing from this report.

 The error described ('value is on database "default"') is part of the
 multi-db machinery, which wasn't added until 1.2.

 However, the example as provided wont *ever* work, 1.1 or otherwise:
 {{{
 >>> t1, created = Tag.objects.get_or_create(name='tag1')
 >>> t2, created = Tag.objects.get_or_create(name='tag2')

 >>> p1 = Photo()
 >>> p1.tags = [t1,t2]
 ValueError: "'Photo' instance needs to have a primary key value before a
 many-to-many relationship can be used."
 }}}

 This is the expected behavior -- you can't assign m2m objects until the
 base object is saved. I've run this test on the tips of the 1.1.X, 1.2.X
 and trunk branches.

 The error you describe is consistent with the cross-database protections
 kicking in. It's possible that there might have been some changes that
 have broken these cross-database protections, but we will more details to
 verify that this is the case -- in particular, any details of your routing
 setup.

 Closing worksforme; feel free to reopen if you can provide a complete test
 case that reproduces the problem you are seeing.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/14849#comment:1>
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 django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to