Ticket #340 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

Table creation for models with only a single local field fails

Reported by: tommi@… Owned by: andrew
Priority: minor Milestone: 0.7
Component: commands Version: 0.7-pre
Keywords: Cc:

Description

Hi,

I noticed that South creates erroneous migration code in case of only one local field.

E.g. for model in app

buggy
class Target(models.Model):
    pass

following migration is created:

# encoding: utf-8
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models

class Migration(SchemaMigration):
    
    def forwards(self, orm):
        
        # Adding model 'Target'
        db.create_table('buggy_target', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True))
        ))
        db.send_create_signal('buggy', ['Target'])
    
    
    def backwards(self, orm):
        
        # Deleting model 'Target'
        db.delete_table('buggy_target')
    
    
    models = {
        'buggy.target': {
            'Meta': {'object_name': 'Target', 'managed': 'True'},
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
        }
    }
    
    complete_apps = ['buggy']

And there we're missing a comma after the

('id', self.gf('django.db.models.fields.AutoField')(primary_key=True))

and thus unpacking in

create_table

fails.

Attached is a patch (diffed against 626:3c55f23ca089).

-Tommi Penttinen-

Attachments

single_field_model_creation_fails.diff (443 bytes) - added by tommi@… 5 years ago.

Change History

Changed 5 years ago by tommi@…

comment:1 Changed 5 years ago by anonymous

Bugger, mispressed the submit button. But for completeness, I meant 'south.db.generic.create_table' with 'create_table'.

And although 'Target' as itself would be kind of useless, models with only many-to-many relationships would not contain any other local fields either.

-Tommi Penttinen-

comment:2 Changed 5 years ago by andrew

  • Status changed from new to closed
  • Resolution set to fixed
  • Milestone set to 0.7

Fixed in [d2cb8cb7060a].

Note: See TracTickets for help on using tickets.