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 o2o relation #663

Merged
merged 3 commits into from Jun 9, 2019
Merged

Conversation

robertpro
Copy link
Contributor

@robertpro robertpro commented Jun 9, 2019

This PR fixes: #662

I tested manually like this:

def get_reverse_fields(model, local_field_names):
    for name, attr in model.__dict__.items():
        # Don't duplicate any local fields
        if name in local_field_names:
            continue
        r = getattr(attr, "rel", None)
        r2 = getattr(attr, "related", None)

        if r is not None or r2 is not None:
            print(r, r2)

        related = getattr(attr, "rel", None)
        if isinstance(related, models.ManyToOneRel):
            yield (name, related)
        elif isinstance(related, models.ManyToManyRel) and not related.symmetrical:
            yield (name, related)

And the result (on runserver output):

<ManyToOneRel: event.companion> None
None <OneToOneRel: event.invitation>

Which means O2O relation is still using "related"

@coveralls
Copy link

coveralls commented Jun 9, 2019

Coverage Status

Coverage remained the same at 92.718% when pulling 94602c7 on robertpro:fix-o2o-relation into bad8e13 on graphql-python:master.

Copy link
Member

@mvanlonden mvanlonden left a comment

Choose a reason for hiding this comment

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

Thank you!

@mvanlonden mvanlonden merged commit ab551f4 into graphql-python:master Jun 9, 2019
@robertpro robertpro deleted the fix-o2o-relation branch October 10, 2022 16:55
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.

OneToOne Relations stop working on 2.3.0
4 participants