Ticket #13030: nk_inherit_test.diff
File nk_inherit_test.diff, 2.3 KB (added by , 15 years ago) |
---|
-
regressiontests/fixtures_regress/fixtures/nk-inheritance.json
1 [ 2 {"pk": 1, "model": "fixtures_regress.parent", "fields": {"name": "fred"}}, 3 4 {"pk": 1, "model": "fixtures_regress.child", "fields": {"data": "apple"}}, 5 {"pk": 1, "model": "fixtures_regress.reftochild", "fields": {"text": "my text", "thechild" : 1}}, 6 7 {"pk": 1, "model": "fixtures_regress.nkchild", "fields": {"data": "apple"}}, 8 {"pk": 1, "model": "fixtures_regress.reftonkchild", "fields": {"text": "my text", "thenkchild" : ["apple"]}} 9 ] -
regressiontests/fixtures_regress/models.py
55 55 class Child(Parent): 56 56 data = models.CharField(max_length=10) 57 57 58 class NKManager(models.Manager): 59 def get_by_natural_key(self, data): 60 return self.get(data=data) 61 class NKChild(Parent): 62 data = models.CharField(max_length=10, unique=True) 63 objects = NKManager() 64 def natural_key(self): 65 return self.data 66 67 class RefToChild(models.Model): 68 text = models.CharField(max_length=10) 69 thechild = models.ForeignKey(Child) 70 71 class RefToNKChild(models.Model): 72 text = models.CharField(max_length=10) 73 thenkchild = models.ForeignKey(NKChild) 74 58 75 # Models to regression test #7572 59 76 class Channel(models.Model): 60 77 name = models.CharField(max_length=255) … … 245 262 >>> management.call_command('loaddata', 'model-inheritance.json', verbosity=0) 246 263 247 264 ############################################### 265 # Test for ticket #XXXX -- natural keys deserialize with fk to inheriting model 266 267 # load data with natural keys 268 >>> management.call_command('loaddata', 'nk-inheritance.json', verbosity=0) 269 270 271 ############################################### 248 272 # Test for ticket #7572 -- MySQL has a problem if the same connection is 249 273 # used to create tables, load data, and then query over that data. 250 274 # To compensate, we close the connection after running loaddata.