Skip to content

Unable to provide deferred types #102

@tonthon

Description

@tonthon

Providing custom deferred types results in an error

TypeError: __call__() takes exactly 3 arguments (1 given)

The column

class MyModel(DbBase):
    name = sa.Column(sa.Float(), info={'colanderalchemy': {'typ': deferred_type}})

The deferred type

@colander.deferred
def deferred_type(node, kw):
    if kw['use_float'] == True:
          return colander.Float()
    else:
          return colander.Integer()

When generating the schema with SQLAlchemySchemaNode, we get the error.

The error comes from the fact that a colander.deferred has a 'call' method.

https://github.com/stefanofontanelli/ColanderAlchemy/blob/master/colanderalchemy/schema.py#L286
An exception should be added for colander.deferreds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions