Handle other strategy for sqlite in Django2.2
This commit is contained in:
1 parent
ef2052a7b0
commit
19620d9996
2 files changed
+13
-2
No files matched your search
@@ -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",
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
Reference in new issue
Block a user