From 34decdebf157b6f05836009cc1967f74ee541fdf Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Sun, 8 Sep 2019 20:31:43 -0400 Subject: Fixed #30754 -- Prevented inclusion of aliases in partial index conditions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SQLite doesn't repoint table aliases in partial index conditions on table rename which breaks the documented table alteration procedure. Thanks Pēteris Caune for the report. --- tests/indexes/tests.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/indexes/tests.py b/tests/indexes/tests.py index ecc449ed4a..2272cadc4f 100644 --- a/tests/indexes/tests.py +++ b/tests/indexes/tests.py @@ -108,7 +108,7 @@ class PartialIndexConditionIgnoredTests(TransactionTestCase): editor.add_index(Article, index) self.assertNotIn( - 'WHERE %s.%s' % (editor.quote_name(Article._meta.db_table), 'published'), + 'WHERE %s' % editor.quote_name('published'), str(index.create_sql(Article, editor)) ) @@ -258,7 +258,7 @@ class PartialIndexTests(TransactionTestCase): ) ) self.assertIn( - 'WHERE %s.%s' % (editor.quote_name(Article._meta.db_table), editor.quote_name("pub_date")), + 'WHERE %s' % editor.quote_name('pub_date'), str(index.create_sql(Article, schema_editor=editor)) ) editor.add_index(index=index, model=Article) @@ -275,7 +275,7 @@ class PartialIndexTests(TransactionTestCase): condition=Q(pk__gt=1), ) self.assertIn( - 'WHERE %s.%s' % (editor.quote_name(Article._meta.db_table), editor.quote_name('id')), + 'WHERE %s' % editor.quote_name('id'), str(index.create_sql(Article, schema_editor=editor)) ) editor.add_index(index=index, model=Article) @@ -292,7 +292,7 @@ class PartialIndexTests(TransactionTestCase): condition=Q(published=True), ) self.assertIn( - 'WHERE %s.%s' % (editor.quote_name(Article._meta.db_table), editor.quote_name('published')), + 'WHERE %s' % editor.quote_name('published'), str(index.create_sql(Article, schema_editor=editor)) ) editor.add_index(index=index, model=Article) @@ -319,7 +319,7 @@ class PartialIndexTests(TransactionTestCase): sql = str(index.create_sql(Article, schema_editor=editor)) where = sql.find('WHERE') self.assertIn( - 'WHERE (%s.%s' % (editor.quote_name(Article._meta.db_table), editor.quote_name("pub_date")), + 'WHERE (%s' % editor.quote_name('pub_date'), sql ) # Because each backend has different syntax for the operators, @@ -339,7 +339,7 @@ class PartialIndexTests(TransactionTestCase): condition=Q(pub_date__isnull=False), ) self.assertIn( - 'WHERE %s.%s IS NOT NULL' % (editor.quote_name(Article._meta.db_table), editor.quote_name("pub_date")), + 'WHERE %s IS NOT NULL' % editor.quote_name('pub_date'), str(index.create_sql(Article, schema_editor=editor)) ) editor.add_index(index=index, model=Article) -- cgit v1.3