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

🐛 Fix get with using_key #2042

Merged
merged 4 commits into from
Oct 10, 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
2 changes: 1 addition & 1 deletion lamindb/_query_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def get(
else:
assert idlike is None # noqa: S101
expressions = process_expressions(registry, expressions)
return registry.objects.get(**expressions)
return registry.objects.using(qs.db).get(**expressions)


class RecordsList(UserList):
Expand Down
2 changes: 2 additions & 0 deletions lamindb/_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ def using(
instance: str | None,
) -> QuerySet:
"""{}""" # noqa: D415
from ._query_set import QuerySet

if instance is None:
return QuerySet(model=cls, using=None)
owner, name = get_owner_name_from_identifier(instance)
Expand Down
5 changes: 5 additions & 0 deletions tests/core/test_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,8 @@ def test_get_name_field():
with pytest.raises(ValueError):
_record.get_name_field(ln.Artifact.ulabels.through())
transform.delete()


def test_using():
ln.Artifact.using("laminlabs/lamin-site-assets").get(1)
ln.Artifact.using("laminlabs/lamin-site-assets").get(uid="MqEaGU7fXvxNy61R0000")
Loading