Ticket #15304: 15304-pk-type-r15539.diff
File 15304-pk-type-r15539.diff, 1.9 KB (added by , 14 years ago) |
---|
-
docs/intro/tutorial01.txt
534 534 # Save the object into the database. You have to call save() explicitly. 535 535 >>> p.save() 536 536 537 # Now it has an ID. Note that this might say "1L" instead of "1", depending 538 # on which database you're using. That's no biggie; it just means your 539 # database backend prefers to return integers as Python long integer 540 # objects. 537 # Now it has an ID. 541 538 >>> p.id 542 539 1 543 540 -
tests/regressiontests/model_regress/tests.py
163 163 1 164 164 ) 165 165 166 def test_pk_type(self): 167 # Make sure that the primary key value of newly created objects is the 168 # same type as existing objects. 169 p = Party.objects.create() 170 p2 = Party.objects.get(pk=p.pk) 171 self.assertEqual(type(p.pk), type(p2.pk)) 172 166 173 class ModelValidationTest(TestCase): 167 174 def test_pk_validation(self): 168 175 one = NonAutoPK.objects.create(name="one") -
django/db/models/base.py
556 556 result = manager._insert([(meta.pk, connection.ops.pk_default_value())], return_id=update_pk, raw_values=True, using=using) 557 557 558 558 if update_pk: 559 setattr(self, meta.pk.attname, result)559 setattr(self, meta.pk.attname, meta.auto_field.to_python(result)) 560 560 transaction.commit_unless_managed(using=using) 561 561 562 562 # Store the database on which the object was saved