Opened 8 years ago

Closed 8 years ago

#24071 closed Bug (duplicate)

Error with sqlmigrate

Reported by: djbug Owned by: nobody
Component: Migrations Version: 1.7
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I have an app where I create a simple table and then add a partial index directly in SQL using RunSQL & migrations. I get an error with sqlmigrate when I use it on a custom migration.

The command is : sqlmigrate myapp files looks like this:

class Migration(migrations.Migration):

    dependencies = [
        ('myapp', '0001_initial'),

    operations = [
            sql = 'CREATE UNIQUE INDEX test_idx ON book (name, publisher_id) WHERE publisher_id IS NOT NULL;',

Here's the error:

(django1_7) C:\djangoproject>python sqlmigrate myapp 0002

Traceback (most recent call last):
  File "", line 10, in <module>
  File "C:\virtualenv\django1_7\lib\site-packages\django\core\management\", line 385, in execute_from_command_line
  File "C:\virtualenv\django1_7\lib\site-packages\django\core\management\", line 377, in execute
  File "C:\virtualenv\django1_7\lib\site-packages\django\core\management\", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "C:\virtualenv\django1_7\lib\site-packages\django\core\management\commands\", line 30, in execute
    return super(Command, self).execute(*args, **options)
  File "C:\virtualenv\django1_7\lib\site-packages\django\core\management\", line 338, in execute
    output = self.handle(*args, **options)
  File "C:\virtualenv\django1_7\lib\site-packages\django\core\management\commands\", line 61, in handle
    sql_statements = executor.collect_sql(plan)
  File "C:\virtualenv\django1_7\lib\site-packages\django\db\migrations\", line 77, in collect_sql
    migration.apply(project_state, schema_editor, collect_sql=True)
  File "C:\virtualenv\django1_7\lib\site-packages\django\db\migrations\", line 107, in apply
    operation.database_forwards(self.app_label, schema_editor, project_state, new_state)
  File "C:\virtualenv\django1_7\lib\site-packages\django\db\migrations\operations\", line 69, in database_forwards
    schema_editor.execute(statement, params=None)
  File "C:\virtualenv\django1_7\lib\site-packages\django\db\backends\", line 96, in execute
    self.collected_sql.append((sql % tuple(map(self.quote_value, params))) + ";")
TypeError: argument 2 to map() must support iteration

Change History (1)

comment:1 Changed 8 years ago by Claude Paroz

Resolution: duplicate
Status: newclosed

Duplicate of #23909 (should be fixed very soon in 1.7.2)

Note: See TracTickets for help on using tickets.
Back to Top