mirror of https://github.com/django/django.git
Added DatabaseIntrospection.index_default_access_method hook on the PostgreSQL backend.
This hook is for the CockroachDB backend where the name is 'prefix'.
This commit is contained in:
parent
e11d05e0b4
commit
7f2392981d
|
@ -28,6 +28,8 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
|
|||
2950: 'UUIDField',
|
||||
3802: 'JSONField',
|
||||
}
|
||||
# A hook for subclasses.
|
||||
index_default_access_method = 'btree'
|
||||
|
||||
ignored_tables = []
|
||||
|
||||
|
@ -189,7 +191,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
|
|||
pg_get_indexdef(idx.indexrelid)
|
||||
END AS exprdef,
|
||||
CASE am.amname
|
||||
WHEN 'btree' THEN
|
||||
WHEN %s THEN
|
||||
CASE (option & 1)
|
||||
WHEN 1 THEN 'DESC' ELSE 'ASC'
|
||||
END
|
||||
|
@ -206,10 +208,15 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
|
|||
WHERE c.relname = %s AND pg_catalog.pg_table_is_visible(c.oid)
|
||||
) s2
|
||||
GROUP BY indexname, indisunique, indisprimary, amname, exprdef, attoptions;
|
||||
""", [table_name])
|
||||
""", [self.index_default_access_method, table_name])
|
||||
for index, columns, unique, primary, orders, type_, definition, options in cursor.fetchall():
|
||||
if index not in constraints:
|
||||
basic_index = type_ == 'btree' and not index.endswith('_btree') and options is None
|
||||
basic_index = (
|
||||
type_ == self.index_default_access_method and
|
||||
# '_btree' references
|
||||
# django.contrib.postgres.indexes.BTreeIndex.suffix.
|
||||
not index.endswith('_btree') and options is None
|
||||
)
|
||||
constraints[index] = {
|
||||
"columns": columns if columns != [None] else [],
|
||||
"orders": orders if orders != [None] else [],
|
||||
|
|
Loading…
Reference in New Issue