Refs #28909 -- Simplifed code using unpacking generalizations.
This commit is contained in:
parent
ebc4ee3369
commit
f3a98224e6
|
@ -865,8 +865,7 @@ class BaseDatabaseSchemaEditor:
|
||||||
and a unique digest and suffix.
|
and a unique digest and suffix.
|
||||||
"""
|
"""
|
||||||
_, table_name = split_identifier(table_name)
|
_, table_name = split_identifier(table_name)
|
||||||
hash_data = [table_name] + list(column_names)
|
hash_suffix_part = '%s%s' % (self._digest(table_name, *column_names), suffix)
|
||||||
hash_suffix_part = '%s%s' % (self._digest(*hash_data), suffix)
|
|
||||||
max_length = self.connection.ops.max_name_length() or 200
|
max_length = self.connection.ops.max_name_length() or 200
|
||||||
# If everything fits into max_length, use that name.
|
# If everything fits into max_length, use that name.
|
||||||
index_name = '%s_%s_%s' % (table_name, '_'.join(column_names), hash_suffix_part)
|
index_name = '%s_%s_%s' % (table_name, '_'.join(column_names), hash_suffix_part)
|
||||||
|
|
|
@ -85,22 +85,17 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
|
||||||
|
|
||||||
fields = []
|
fields = []
|
||||||
for line in cursor.description:
|
for line in cursor.description:
|
||||||
col_name = line[0]
|
info = field_info[line[0]]
|
||||||
fields.append(
|
fields.append(FieldInfo(
|
||||||
FieldInfo(*(
|
*line[:3],
|
||||||
(col_name,) +
|
to_int(info.max_len) or line[3],
|
||||||
line[1:3] +
|
to_int(info.num_prec) or line[4],
|
||||||
(
|
to_int(info.num_scale) or line[5],
|
||||||
to_int(field_info[col_name].max_len) or line[3],
|
|
||||||
to_int(field_info[col_name].num_prec) or line[4],
|
|
||||||
to_int(field_info[col_name].num_scale) or line[5],
|
|
||||||
line[6],
|
line[6],
|
||||||
field_info[col_name].column_default,
|
info.column_default,
|
||||||
field_info[col_name].extra,
|
info.extra,
|
||||||
field_info[col_name].is_unsigned,
|
info.is_unsigned,
|
||||||
)
|
|
||||||
))
|
))
|
||||||
)
|
|
||||||
return fields
|
return fields
|
||||||
|
|
||||||
def get_sequences(self, cursor, table_name, table_fields=()):
|
def get_sequences(self, cursor, table_name, table_fields=()):
|
||||||
|
|
|
@ -84,13 +84,10 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
|
||||||
name = desc[0]
|
name = desc[0]
|
||||||
internal_size, default, is_autofield = field_map[name]
|
internal_size, default, is_autofield = field_map[name]
|
||||||
name = name % {} # cx_Oracle, for some reason, doubles percent signs.
|
name = name % {} # cx_Oracle, for some reason, doubles percent signs.
|
||||||
description.append(FieldInfo(*(
|
description.append(FieldInfo(
|
||||||
(name.lower(),) +
|
name.lower(), *desc[1:3], internal_size, desc[4] or 0,
|
||||||
desc[1:3] +
|
desc[5] or 0, *desc[6:], default, is_autofield,
|
||||||
(internal_size, desc[4] or 0, desc[5] or 0) +
|
))
|
||||||
desc[6:] +
|
|
||||||
(default, is_autofield)
|
|
||||||
)))
|
|
||||||
return description
|
return description
|
||||||
|
|
||||||
def table_name_converter(self, name):
|
def table_name_converter(self, name):
|
||||||
|
|
|
@ -75,7 +75,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
|
||||||
field_map = {line[0]: line[1:] for line in cursor.fetchall()}
|
field_map = {line[0]: line[1:] for line in cursor.fetchall()}
|
||||||
cursor.execute("SELECT * FROM %s LIMIT 1" % self.connection.ops.quote_name(table_name))
|
cursor.execute("SELECT * FROM %s LIMIT 1" % self.connection.ops.quote_name(table_name))
|
||||||
return [
|
return [
|
||||||
FieldInfo(*(line[0:6] + (field_map[line.name][0] == 'YES', field_map[line.name][1])))
|
FieldInfo(*line[0:6], field_map[line.name][0] == 'YES', field_map[line.name][1])
|
||||||
for line in cursor.description
|
for line in cursor.description
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -1056,7 +1056,7 @@ class CheckCondition:
|
||||||
self.conditions = conditions
|
self.conditions = conditions
|
||||||
|
|
||||||
def add_condition(self, condition, reason):
|
def add_condition(self, condition, reason):
|
||||||
return self.__class__(*self.conditions + ((condition, reason),))
|
return self.__class__(*self.conditions, (condition, reason))
|
||||||
|
|
||||||
def __get__(self, instance, cls=None):
|
def __get__(self, instance, cls=None):
|
||||||
# Trigger access for all bases.
|
# Trigger access for all bases.
|
||||||
|
|
|
@ -9,7 +9,7 @@ from functools import total_ordering, wraps
|
||||||
# CPython) is a type and its instances don't bind.
|
# CPython) is a type and its instances don't bind.
|
||||||
def curry(_curried_func, *args, **kwargs):
|
def curry(_curried_func, *args, **kwargs):
|
||||||
def _curried(*moreargs, **morekwargs):
|
def _curried(*moreargs, **morekwargs):
|
||||||
return _curried_func(*(args + moreargs), **{**kwargs, **morekwargs})
|
return _curried_func(*args, *moreargs, **{**kwargs, **morekwargs})
|
||||||
return _curried
|
return _curried
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue