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 | August 2023 #669

Merged
merged 24 commits into from Sep 13, 2023
Merged

Fix | August 2023 #669

merged 24 commits into from Sep 13, 2023

Conversation

roman-right
Copy link
Member

No description provided.

@Mark90
Copy link

Mark90 commented Aug 24, 2023

As promised in #599 I'd leave a message here about the new error I'm seeing with this branch.

In summary what I think is happening is that the .fetch_all_links() works now (it doesn't give an AttributeError anymore as it did with 1.21.0) but it doesn't seem to handle nested linked documents.

My simplified document structure is like this

class Email(Document):
  ... 

class Log(Document):
  emails: list[Link[Email]]

class Ticket(Document):
  logs: list[Link[Log]]

When I have an existing Ticket instance and call .fetch_all_links() on it, it resolves the links up until ticket.logs[]; but all the ticket.logs[].emails[] are still of type beanie.odm.fields.Link.

This is also the case when I do Ticket.get(ticket_uuid, fetch_links=True).

And actually I get the same output with Ticket.get(ticket_uuid, fetch_links=False) where I would have expected ticket.logs[] to be of type Link, but they're already fetched.

@roman-right roman-right merged commit bc23332 into main Sep 13, 2023
22 checks passed
@roman-right roman-right deleted the fix/aug_2023 branch September 13, 2023 19:15
if isinstance(value, dict):
internal_key = list(value.keys())[0]
if internal_key.startswith("$"):
return {expression_key: {"$not": value}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roman-right is the (omitted) else part here even valid, e.g. {"$not": {"foo": 3}}? All the examples I have seen with dict value are operator expressions, i.e. the condition here is always true. If that's the case this can be simplified. The added test doesn't cover this case so I can't tell for sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants