#26884: update_or_create does not evaluate callables in defaults for update case
----------------------------------------------+----------------------------
     Reporter:  jensen-cochran                |      Owner:  nobody
         Type:  Uncategorized                 |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  master
     Severity:  Normal                        |   Keywords:
                                              |  update_or_create
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+----------------------------
 Ticket #26638 added support for accepting callables in the 'defaults'
 parameter of get_or_create and update_or_create.  In the case where
 update_or_create is updating, the callables are not evaluated.  I have
 written a test for update_or_create that demonstrates this behavior
 (attached).

 Here is the traceback for that test failure:

 {{{
 ======================================================================
 FAIL: test_update_callable_default
 (get_or_create.tests.UpdateOrCreateTests)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "/usr/lib64/python2.7/unittest/case.py", line 369, in run
     testMethod()
   File "/home/default/sandbox/django/tests/get_or_create/tests.py", line
 423, in test_update_callable_default
     self.assertEqual(obj.last_name, 'NotHarrison')
   File "/usr/lib64/python2.7/unittest/case.py", line 553, in assertEqual
     assertion_func(first, second, msg=msg)
   File "/usr/lib64/python2.7/unittest/case.py", line 546, in
 _baseAssertEqual
     raise self.failureException(msg)
 AssertionError: <function <lambda> at 0x22d0320> != u'NotHarrison'

 ----------------------------------------------------------------------
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26884>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/057.c2afdd6bd83790b46c4802c2438260a5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to