flying-sheep / graphql-sqlalchemy

Generate GraphQL Schemas from your SQLAlchemy models

Home Page:https://graphql-sqlalchemy.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

many2one relationship attribute comparison in `where` fails

flying-sheep opened this issue · comments

{
  skill(
    where: {_and: [{id: {_like: "%&%"}}, {primary_principle: {id: {_eq: "knock"}}}]}
  ) {
    id
    primary_principle {
      id
    }
  }
}

raises

Traceback (most recent call last):
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/sqlalchemy/orm/attributes.py", line 472, in __getattr__
    return getattr(self.comparator, key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/sqlalchemy/util/langhelpers.py", line 1328, in __getattr__
    return self._fallback_getattr(key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/sqlalchemy/util/langhelpers.py", line 1297, in _fallback_getattr
    raise AttributeError(key)
AttributeError: id

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/graphql/execution/execute.py", line 521, in execute_field
    result = resolve_fn(source, info, **args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/graphql_sqlalchemy/resolvers.py", line 187, in resolver
    return resolve_filtered(model, query, where=where, order=order, limit=limit, offset=offset)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/graphql_sqlalchemy/resolvers.py", line 129, in resolve_filtered
    query = filter_query(model, query, where)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/graphql_sqlalchemy/resolvers.py", line 98, in filter_query
    query = query_filter(get_filter_operation(model, {name: exprs}))
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/graphql_sqlalchemy/resolvers.py", line 72, in get_filter_operation
    return and_(*map(partial_filter, exprs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/graphql_sqlalchemy/resolvers.py", line 81, in get_filter_operation
    return get_filter_operation(model_property, exprs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/graphql_sqlalchemy/resolvers.py", line 74, in get_filter_operation
    model_property: InstrumentedAttribute = getattr(model, name)
                                            ^^^^^^^^^^^^^^^^^^^^
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/sqlalchemy/orm/attributes.py", line 474, in __getattr__
    raise AttributeError(
AttributeError: Neither 'InstrumentedAttribute' object nor 'Comparator' object associated with Skill.primary_principle has an attribute 'id'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/graphql/execution/execute.py", line 1030, in execute
    result = exe_context.execute_operation(operation, root_value)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/graphql/execution/execute.py", line 353, in execute_operation
    return (
           ^
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/graphql/execution/execute.py", line 431, in execute_fields
    result = self.execute_field(
             ^^^^^^^^^^^^^^^^^^^
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/graphql/execution/execute.py", line 558, in execute_field
    self.handle_field_error(error, return_type)
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/graphql/execution/execute.py", line 569, in handle_field_error
    raise error
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/graphql/execution/execute.py", line 521, in execute_field
    result = resolve_fn(source, info, **args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/graphql_sqlalchemy/resolvers.py", line 187, in resolver
    return resolve_filtered(model, query, where=where, order=order, limit=limit, offset=offset)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/graphql_sqlalchemy/resolvers.py", line 129, in resolve_filtered
    query = filter_query(model, query, where)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/graphql_sqlalchemy/resolvers.py", line 98, in filter_query
    query = query_filter(get_filter_operation(model, {name: exprs}))
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/graphql_sqlalchemy/resolvers.py", line 72, in get_filter_operation
    return and_(*map(partial_filter, exprs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/graphql_sqlalchemy/resolvers.py", line 81, in get_filter_operation
    return get_filter_operation(model_property, exprs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/graphql_sqlalchemy/resolvers.py", line 74, in get_filter_operation
    model_property: InstrumentedAttribute = getattr(model, name)
                                            ^^^^^^^^^^^^^^^^^^^^
  File "/home/phil/.local/share/hatch/env/virtual/boh-app/p2Kp3Htt/boh-app/lib/python3.11/site-packages/sqlalchemy/orm/attributes.py", line 474, in __getattr__
    raise AttributeError(
graphql.error.graphql_error.GraphQLError: Neither 'InstrumentedAttribute' object nor 'Comparator' object associated with Skill.primary_principle has an attribute 'id'