Skip to content

Commit

Permalink
Fixed #24424: sqlite syntax error on migrating abstract model
Browse files Browse the repository at this point in the history
  • Loading branch information
adnam committed Feb 27, 2015
1 parent 7182072 commit 69575fd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions django/db/backends/sqlite3/schema.py
Expand Up @@ -137,10 +137,14 @@ def _remake_table(self, model, create_fields=[], delete_fields=[], alter_fields=
self.create_model(temp_model)
# Copy data from the old table
field_maps = list(mapping.items())
insert_fields, select_fields = "", "*"
if field_maps != []:
insert_fields = "(" + ', '.join(self.quote_name(x) for x, y in field_maps) + ")"
select_fields = ', '.join(y for x, y in field_maps)
self.execute("INSERT INTO %s (%s) SELECT %s FROM %s" % (
self.quote_name(temp_model._meta.db_table),
', '.join(self.quote_name(x) for x, y in field_maps),
', '.join(y for x, y in field_maps),
insert_fields,
select_fields,
self.quote_name(model._meta.db_table),
))
# Delete the old table
Expand Down

0 comments on commit 69575fd

Please sign in to comment.