Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for positional arguments when instantiating a document #2103

Merged
merged 5 commits into from
Jun 26, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cleaner loop using itertools.count()
wojcikstefan committed Jun 25, 2019
commit 0578cdb62ef762454941e872ca026ada5a01e5f9
5 changes: 2 additions & 3 deletions mongoengine/base/metaclasses.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import itertools
import warnings

import six
@@ -440,16 +441,14 @@ def get_auto_id_names(mcs, new_class):
return id_name, id_db_name

id_basename, id_db_basename, i = ('auto_id', '_auto_id', 0)
while True:
for i in itertools.count():
id_name = '{0}_{1}'.format(id_basename, i)
id_db_name = '{0}_{1}'.format(id_db_basename, i)
if (
id_name not in existing_fields and
id_db_name not in existing_db_fields
):
return id_name, id_db_name
else:
i += 1


class MetaDict(dict):