Add Postgresql warning when using CREATE INDEX without CONCURRENTLY keyword
This commit is contained in:
1 parent
9ea8872a29
commit
343d163c88
3 files changed
+31
-4
No files matched your search
@@ -14,13 +14,17 @@ class SqlAnalyserTestCase(unittest.TestCase):
|
||||
)
|
||||
|
||||
def assertValidSql(self, sql):
|
||||
errors, _ = self.analyse_sql(sql)
|
||||
errors, _, _ = self.analyse_sql(sql)
|
||||
self.assertEqual(0, len(errors), "Found errors in sql: {}".format(errors))
|
||||
|
||||
def assertBackwardIncompatibleSql(self, sql):
|
||||
errors, _ = self.analyse_sql(sql)
|
||||
errors, _, _ = self.analyse_sql(sql)
|
||||
self.assertNotEqual(0, len(errors), "Found no errors in sql")
|
||||
|
||||
def assertWarningSql(self, sql):
|
||||
_, _, warnings = self.analyse_sql(sql)
|
||||
self.assertNotEqual(0, len(warnings), "Found no warnings in sql")
|
||||
|
||||
|
||||
class MySqlAnalyserTestCase(SqlAnalyserTestCase):
|
||||
database_vendor = "mysql"
|
||||
@@ -203,3 +207,15 @@ class PostgresqlAnalyserTestCase(SqlAnalyserTestCase):
|
||||
'ALTER TABLE "app_drop_default_a" ALTER COLUMN "col" SET DEFAULT `\'empty\';',
|
||||
]
|
||||
self.assertValidSql(sql)
|
||||
|
||||
def test_create_index_non_concurrently(self):
|
||||
sql = "CREATE INDEX ON films ((lower(titre)));"
|
||||
self.assertWarningSql(sql)
|
||||
sql = "CREATE UNIQUE INDEX title_idx ON films (title);"
|
||||
self.assertWarningSql(sql)
|
||||
|
||||
def test_create_index_concurrently(self):
|
||||
sql = "CREATE INDEX CONCURRENTLY ON films ((lower(titre)));"
|
||||
self.assertValidSql(sql)
|
||||
sql = "CREATE UNIQUE INDEX CONCURRENTLY title_idx ON films (title);"
|
||||
self.assertValidSql(sql)
|
||||
Reference in new issue
Block a user