Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#392 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python, sqlalchemy
Domain
backend, databases

Research direction

Start by reproducing the BusinessPriority and MetricView model definitions shown in the issue, focusing on the relationship entry point and how the primary-key attribute is looked up. Done means a model whose database column is named id but whose Python attribute is row_id can be queried through the relationship without requiring an id attribute.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Python
Stars
985
Forks
224
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from graphql-python/graphene-sqlalchemy

All issues in graphql-python/graphene-sqlalchemy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.