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

Ensure that new collection immutable_id is returned upon creation #925

Merged
merged 4 commits into from
Oct 14, 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
11 changes: 9 additions & 2 deletions pydatalab/src/pydatalab/routes/v0_1/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def create_collection():
400,
)

immutable_id = result.inserted_id
data_model.immutable_id = result.inserted_id

errors = []
if starting_members:
Expand All @@ -177,7 +177,14 @@ def create_collection():
"item_id": {"$in": list(item_ids)},
**get_default_permissions(user_only=True),
},
{"$push": {"relationships": {"type": "collections", "immutable_id": immutable_id}}},
{
"$push": {
"relationships": {
"type": "collections",
"immutable_id": data_model.immutable_id,
}
}
},
)

data_model.num_items = results.modified_count
Expand Down
1 change: 1 addition & 0 deletions pydatalab/tests/server/test_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ def test_create_collections(client, default_collection):
assert response.json["data"]["collection_id"] == "test_collection"
assert response.json["data"]["title"] == "My Test Collection"
assert response.json["data"]["num_items"] == 0
assert response.json["data"]["immutable_id"]

response = client.get("/collections")
assert response.status_code == 200
Expand Down
Loading