Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Commit

Permalink
Fixing an error in sqlite schema grammar when a column's name is a ke…
Browse files Browse the repository at this point in the history
…yword

Fixes #32
  • Loading branch information
sdispater committed Dec 22, 2015
1 parent 7fa9dbe commit 7b867b3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions orator/schema/grammars/sqlite_grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def compile_rename_column(self, blueprint, command, connection):
# We reinsert the data into the new table
sql.append('INSERT INTO %s (%s) SELECT %s FROM %s'
% (self.wrap_table(table),
', '.join(new_column_names),
self.columnize(new_column_names),
self.columnize(old_column_names),
self.wrap_table(temp_table)
))
Expand Down Expand Up @@ -262,8 +262,8 @@ def compile_change(self, blueprint, command, connection):
sql += new_blueprint.to_sql(None, self)
sql.append('INSERT INTO %s (%s) SELECT %s FROM %s'
% (self.wrap_table(table),
', '.join(sorted(new_column_names)),
self.columnize(sorted(list(map(lambda x: x.get_name(), columns)))),
self.columnize(new_column_names),
self.columnize(list(map(lambda x: x.get_name(), columns))),
self.wrap_table(temp_table)
))
sql += Blueprint(temp_table).drop().to_sql(None, self)
Expand Down
1 change: 1 addition & 0 deletions tests/schema/integrations/test_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def setUp(self):
table.integer('user_id')
table.string('name').unique()
table.string('status').default('draft').nullable()
table.string('default').default(0)
table.timestamps()

table.foreign('user_id').references('id').on('users')
Expand Down

0 comments on commit 7b867b3

Please sign in to comment.