Skip to content

[BUG] No conversion for PostgreSQL INET Type #68

Closed
@scotmatson

Description

@scotmatson

Still working this one out, but I believe the error I am receiving is due to a lack of conversion mechanisms in support of the PostgreSQL INET type (see below).

from sqlalchemy.dialects.postgresql import INET
... = Column(INET, ...)

Changing Column type to String does stop the error from occurring.. so sadly yes this is the issue. Fortunately it doesn't appear I need to modify by database, just the model. It would be great to get better type support.

I imagine we just need a means to translate INET into a string and view it as a scalar. Running type() against this field in the terminal returns the INET value as a string, so the mechanism already appears to be in place, it just needs to be supported in graphene_sqla

Traceback (most recent call last):
  File "run.wsgi", line 1, in <module>
    from app import create_app
  File "/srv/www/edge/server/app/__init__.py", line 5, in <module>
    from app.schema import schema
  File "/srv/www/edge/server/app/schema.py", line 7, in <module>
    from app.types import Viewer
  File "/srv/www/edge/server/app/types/__init__.py", line 10, in <module>
    from .watch import Watch
  File "/srv/www/edge/server/app/types/watch.py", line 11, in <module>
    class Watch(SQLAlchemyObjectType):
  File "/srv/www/edge/server/venv/lib/python3.5/site-packages/graphene_sqlalchemy/types.py", line 104, in __new__
    construct_fields(options),
  File "/srv/www/edge/server/venv/lib/python3.5/site-packages/graphene_sqlalchemy/types.py", line 36, in construct_fields
    converted_column = convert_sqlalchemy_column(column, options.registry)
  File "/srv/www/edge/server/venv/lib/python3.5/site-packages/graphene_sqlalchemy/converter.py", line 82, in convert_sqlalchemy_column
    return convert_sqlalchemy_type(getattr(column, 'type', None), column, registry)
  File "/srv/www/edge/server/venv/lib/python3.5/site-packages/singledispatch.py", line 210, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
  File "/srv/www/edge/server/venv/lib/python3.5/site-packages/graphene_sqlalchemy/converter.py", line 88, in convert_sqlalchemy_type
    "Don't know how to convert the SQLAlchemy field %s (%s)" % (column, column.__class__))
Exception: Don't know how to convert the SQLAlchemy field watches.id_orig_h (<class 'sqlalchemy.sql.schema.Column'>)

I guess while were at it, I imagine I will have the same error when using CIDR types as well from
from sqlalchemy.dialects.postgresql import CIDR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions