8000 fix: autoincrement collection creation by aMahanna · Pull Request #337 · arangodb/python-arango · GitHub
[go: up one dir, main page]

Skip to content

fix: autoincrement collection creation #337

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 a 8000 ccount

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 5 additions & 4 deletions arango/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -1442,10 +1442,11 @@ def create_collection(
:raise arango.exceptions.CollectionCreateError: If create fails.
"""
key_options: Json = {"type": key_generator, "allowUserKeys": user_keys}
if key_increment is not None:
key_options["increment"] = key_increment
if key_offset is not None:
key_options["offset"] = key_offset
if key_generator == "autoincrement":
if key_increment is not None:
key_options["increment"] = key_increment
if key_offset is not None:
key_options["offset"] = key_offset

data: Json = {
"name": name,
Expand Down
11 changes: 9 additions & 2 deletions tests/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,21 @@ def test_collection_management(db, bad_db, cluster):
}
]

col = db.create_collection(
name=col_name, key_generator="autoincrement", key_increment=9, key_offset=100
)
key_options = col.properties()["key_options"]
assert key_options["key_generator"] == "autoincrement"
assert key_options["key_increment"] == 9
assert key_options["key_offset"] == 100
db.delete_collection(col_name)

col = db.create_collection(
name=col_name,
sync=True,
system=False,
key_generator="traditional",
user_keys=False,
key_increment=9,
key_offset=100,
edge=True,
shard_count=2,
shard_fields=["test_attr:"],
Expand Down
Loading
0