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

Relationship isn't working if a model has a property named other than 'id'. #392

Open
masterchef opened this issue Apr 27, 2023 · 5 comments

Comments

@masterchef
Copy link

class BusinessPriority(client.Model):
   metric_views: List['MetricView'] = orm.relationship('MetricView', secondary='business_priority_metrics_link')

class MetricView(client.Model):
    """Data around metric view for Ops Insight"""
    __tablename__ = 'metric_view'

    row_id: Union[Column, int] = Column(name='id', type_=BigInteger, primary_key=True, autoincrement=True)

I get

"errors": [
    {
      "message": "type object 'MetricView' has no attribute 'id'",
      "locations": [
        {
          "line": 8,
          "column": 9
        }
      ],
      "path": [
        "allBusinessPriorities",
        "edges",
        0,
        "node",
        "metricViews"
      ]
    },

But if I change

row_id: Union[Column, int] = Column(name='id', type_=BigInteger, primary_key=True, autoincrement=True)
to
id: Union[Column, int] = Column(name='id', type_=BigInteger, primary_key=True, autoincrement=True)

The join and query works well.

@palisadoes
Copy link
Collaborator

This should have been fixed in this PR. Beware that the syntax for filtering has changed to match that used by Dgraph.

@masterchef
Copy link
Author

Ugh I'm still on version 2.3.0 because we can't use beta versions in our company. When is the v3 planned for GA?

@palisadoes
Copy link
Collaborator

As soon as the filters are done. They are in the final stages of testing. A month or two.

I'm testing the beta with a DB column named id but aliased to id_

@masterchef
Copy link
Author

Thank you! Looking forward to taking advantage of it!

@erikwrede
Copy link
Member

erikwrede commented Dec 4, 2023

Hey @masterchef, we have a release candidate out now https://github.com/graphql-python/graphene-sqlalchemy/releases/tag/v3.0.0rc1

We'd appreciate any feedback before the full release!

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

No branches or pull requests

3 participants