Skip to content

SqlalchemyDataLayer fails on models with __init__ statement #6

@pysalt

Description

@pysalt

Sometimes in projects we use models with __init__ method. something like this:

class Cube(Model):
    x = Column()
    y = Column()
    z = Column()

    def __init__():
        self.x = 10
        self.y = 10

However, a resource with a post method will not work with this model. The create_object method throws a TypeError. This is due to such initialization of the model in this method:

obj = self.model(**{key: value
                            for (key, value) in data.items() if key not in join_fields})

That is, there is no validation of the arguments of the __init__ method.

I suggest using inspect.getfullargspec to determine that a model can only accept a limited list of arguments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions