Handle other strategy for sqlite in Django2.2

This commit is contained in:
David Wobrock committed 2019-07-29 21:05:12 +02:00
1 parent ef2052a7b0
commit 19620d9996
2 files changed
+13 -2

No files matched your search

+4 -2
View File
@@ -83,7 +83,8 @@ sqlite_migration_tests = [
{ {
"code": "RENAME_TABLE", "code": "RENAME_TABLE",
"fn": lambda sql, **kw: re.search("ALTER TABLE .* RENAME TO", sql) "fn": lambda sql, **kw: re.search("ALTER TABLE .* RENAME TO", sql)
and "__old" not in sql, and "__old" not in sql
and "new__" not in sql,
}, },
{ {
"code": "NOT_NULL", "code": "NOT_NULL",
@@ -91,7 +92,8 @@ sqlite_migration_tests = [
re.search("NOT NULL(?! PRIMARY)(?! DEFAULT)", sql) for sql in sql_statements re.search("NOT NULL(?! PRIMARY)(?! DEFAULT)", sql) for sql in sql_statements
) )
and any( and any(
re.search("ALTER TABLE .* RENAME TO", sql) and "__old" in sql re.search("ALTER TABLE .* RENAME TO", sql)
and ("__old" in sql or "new__" in sql)
for sql in sql_statements for sql in sql_statements
), ),
"mode": "transaction", "mode": "transaction",
+9
View File
@@ -101,6 +101,15 @@ class SqliteAnalyserTestCase(SqlAnalyserTestCase):
] ]
self.assertValidSql(sql) self.assertValidSql(sql)
def test_alter_column_after_django22(self):
sql = [
'CREATE TABLE "new__app_alter_column_a" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "field" varchar(10) NULL);',
'INSERT INTO "new__app_alter_column_a" ("id", "field") SELECT "id", "field" FROM "app_alter_column_a";',
'DROP TABLE "app_alter_column_a";',
'ALTER TABLE "new__app_alter_column_a" RENAME TO "app_alter_column_a";',
]
self.assertValidSql(sql)
class PostgresqlAnalyserTestCase(SqlAnalyserTestCase): class PostgresqlAnalyserTestCase(SqlAnalyserTestCase):
database_vendor = "postgresql" database_vendor = "postgresql"