Skip to content

Commit 32a1712

Browse files
committed
Rename function
1 parent a775af8 commit 32a1712

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

django_mongodb_backend/indexes.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from django_mongodb_backend.fields import ArrayField
1515

1616
from .query_utils import process_rhs
17-
from .utils import get_column_path
17+
from .utils import get_field
1818

1919
MONGO_INDEX_OPERATORS = {
2020
"exact": "$eq",
@@ -63,7 +63,7 @@ def get_pymongo_index_model(self, model, schema_editor, field=None, unique=False
6363
filter_expression[column].update({"$type": field.db_type(schema_editor.connection)})
6464
else:
6565
for field_name, _ in self.fields_orders:
66-
field_ = get_column_path(model, field_name)
66+
field_ = get_field(model, field_name)
6767
filter_expression[field_.column].update(
6868
{"$type": field_.db_type(schema_editor.connection)}
6969
)
@@ -76,7 +76,7 @@ def get_pymongo_index_model(self, model, schema_editor, field=None, unique=False
7676
# order is "" if ASCENDING or "DESC" if DESCENDING (see
7777
# django.db.models.indexes.Index.fields_orders).
7878
(
79-
column_prefix + get_column_path(model, field_name).column,
79+
column_prefix + get_field(model, field_name).column,
8080
ASCENDING if order == "" else DESCENDING,
8181
)
8282
for field_name, order in self.fields_orders
@@ -156,7 +156,7 @@ def get_pymongo_index_model(
156156
for field_name, _ in self.fields_orders:
157157
field = model._meta.get_field(field_name)
158158
type_ = self.search_index_data_types(field.db_type(schema_editor.connection))
159-
field_path = column_prefix + get_column_path(model, field_name).column
159+
field_path = column_prefix + get_field(model, field_name).column
160160
fields[field_path] = {"type": type_}
161161
return SearchIndexModel(
162162
definition={"mappings": {"dynamic": False, "fields": fields}}, name=self.name
@@ -266,7 +266,7 @@ def get_pymongo_index_model(
266266
fields = []
267267
for field_name, _ in self.fields_orders:
268268
field_ = model._meta.get_field(field_name)
269-
field_path = column_prefix + get_column_path(model, field_name).column
269+
field_path = column_prefix + get_field(model, field_name).column
270270
mappings = {"path": field_path}
271271
if isinstance(field_, ArrayField):
272272
mappings.update(
@@ -291,9 +291,7 @@ def set_name_with_model(self, model):
291291
fit its size by truncating the excess length.
292292
"""
293293
_, table_name = split_identifier(model._meta.db_table)
294-
column_names = [
295-
get_column_path(model, field_name).column for field_name, order in self.fields_orders
296-
]
294+
column_names = [get_field(model, field_name).column for field_name, order in self.fields_orders]
297295
column_names_with_order = [
298296
(f"-{column_name}" if order else column_name)
299297
for column_name, (field_name, order) in zip(column_names, self.fields_orders, strict=False)

django_mongodb_backend/schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from .fields import EmbeddedModelField
88
from .gis.schema import GISSchemaEditor
99
from .query import wrap_database_errors
10-
from .utils import OperationCollector, get_column_path
10+
from .utils import OperationCollector, get_field
1111

1212

1313
def ignore_embedded_models(func):
@@ -249,7 +249,7 @@ def alter_unique_together(
249249
)
250250
# Created uniques
251251
for field_names in news.difference(olds):
252-
columns = [get_column_path(model, field).column for field in field_names]
252+
columns = [get_field(model, field).column for field in field_names]
253253
name = str(
254254
self._unique_constraint_name(
255255
model._meta.db_table, [column_prefix + col for col in columns]

django_mongodb_backend/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def wrapper(self, *args, **kwargs):
189189
return wrapper
190190

191191

192-
def get_column_path(model, field_name):
192+
def get_field(model, field_name):
193193
from .fields import EmbeddedModelField # noqa: PLC0415
194194

195195
if LOOKUP_SEP in field_name:

0 commit comments

Comments
 (0)