Переглянути джерело

Used None as the empty value for condition in Index's SQL construction.

Paveł Tyślacki 6 роки тому
батько
коміт
1e837c4b23
2 змінених файлів з 2 додано та 2 видалено
  1. 1 1
      django/db/backends/base/schema.py
  2. 1 1
      django/db/models/indexes.py

+ 1 - 1
django/db/backends/base/schema.py

@@ -894,7 +894,7 @@ class BaseDatabaseSchemaEditor:
 
     def _create_index_sql(self, model, fields, *, name=None, suffix='', using='',
                           db_tablespace=None, col_suffixes=(), sql=None, opclasses=(),
-                          condition=''):
+                          condition=None):
         """
         Return the SQL statement to create the index for one or several fields.
         `sql` can be specified if the syntax differs from the standard (GIS

+ 1 - 1
django/db/models/indexes.py

@@ -57,7 +57,7 @@ class Index:
 
     def _get_condition_sql(self, model, schema_editor):
         if self.condition is None:
-            return ''
+            return None
         query = Query(model=model)
         query.add_q(self.condition)
         compiler = query.get_compiler(connection=schema_editor.connection)