From 7b867b3de34f8873ac90be3af96c566f275f6afe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81bastien=20Eustace?= Date: Mon, 21 Dec 2015 20:44:23 -0500 Subject: [PATCH] Fixing an error in sqlite schema grammar when a column's name is a keyword Fixes #32 --- orator/schema/grammars/sqlite_grammar.py | 6 +++--- tests/schema/integrations/test_sqlite.py | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/orator/schema/grammars/sqlite_grammar.py b/orator/schema/grammars/sqlite_grammar.py index 796ecb11..53f9f046 100644 --- a/orator/schema/grammars/sqlite_grammar.py +++ b/orator/schema/grammars/sqlite_grammar.py @@ -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) )) @@ -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) diff --git a/tests/schema/integrations/test_sqlite.py b/tests/schema/integrations/test_sqlite.py index 69533a30..8ae9e7ca 100644 --- a/tests/schema/integrations/test_sqlite.py +++ b/tests/schema/integrations/test_sqlite.py @@ -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')