Modify

Ticket #352 (closed defect: duplicate)

Opened 4 years ago

Last modified 3 years ago

format string as default value for field confuses south

Reported by: yishai@… Owned by: andrew
Priority: major Milestone:
Component: migrations Version: 0.6.2
Keywords: Cc:

Description

A model with a field such as:

 my_format = models.CharField(_('M format'), max_length=30, blank=False, null=False, default='%d')

will cause south to fail with exception:

Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_manager(settings)
  File "c:\python25\lib\site-packages\django_trunk\django\core\management\__init
__.py", line 362, in execute_manager
    utility.execute()
  File "c:\python25\lib\site-packages\django_trunk\django\core\management\__init
__.py", line 303, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "c:\python25\lib\site-packages\django_trunk\django\core\management\base.p
y", line 195, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "c:\python25\lib\site-packages\django_trunk\django\core\management\base.p
y", line 222, in execute
    output = self.handle(*args, **options)
  File "C:\workspace\reco_server\south\management\commands\migrate.py", line 91,
 in handle
    skip = skip,
  File "C:\workspace\reco_server\south\migration.py", line 581, in migrate_app
    result = run_forwards(mapp, [mname], fake=fake, db_dry_run=db_dry_run, verbo
sity=verbosity)
  File "C:\workspace\reco_server\south\migration.py", line 388, in run_forwards
    verbosity = verbosity,
  File "C:\workspace\reco_server\south\migration.py", line 329, in run_migration
s
    runfunc(orm)
  File "C:\workspace\reco_server\campaigns\migrations\0001_initial.py", line 29,
 in forwards
    ('billing_params', orm['campaigns.Campaign:billing_params']),
  File "C:\workspace\reco_server\south\db\generic.py", line 168, in create_table

    self.execute('CREATE TABLE %s (%s);' % (qn(table_name), ', '.join([col for c
ol in columns if col])))
  File "C:\workspace\reco_server\south\db\generic.py", line 86, in execute
    cursor.execute(sql, params)
  File "c:\python25\lib\site-packages\django_trunk\django\db\backends\util.py",
line 22, in execute
    sql = self.db.ops.last_executed_query(self.cursor, sql, params)
  File "c:\python25\lib\site-packages\django_trunk\django\db\backends\__init__.p
y", line 217, in last_executed_query
    return smart_unicode(sql) % u_params
TypeError: not enough arguments for format string

when trying to create the table (initial migration).

Note that '%d' is the actual string value we want to store in the DB as default. Perhaps this needs to be escaped by south?

Attachments

Change History

comment:1 Changed 4 years ago by andrew

  • Status changed from new to closed
  • Resolution set to duplicate

Duplicate of #317. We've already fixed this in trunk; hopefully we'll be releasing it soon.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.