Skip to content

Handle colander.null for mapped schemas in objectify#90

Open
tsauerwein wants to merge 1 commit intostefanofontanelli:masterfrom
tsauerwein:objectify-none
Open

Handle colander.null for mapped schemas in objectify#90
tsauerwein wants to merge 1 commit intostefanofontanelli:masterfrom
tsauerwein:objectify-none

Conversation

@tsauerwein
Copy link

I am having a schema like the following:

    class DocumentGeometry(Base):
        __tablename__ = 'document_geometries'
        id = Column(Integer, primary_key=True)
        document_id = Column(
            Integer, ForeignKey('documents.document_id'),
            nullable=False)
        geom = Column(String)

    class Document(Base):
        __tablename__ = 'documents'

        document_id = Column(Integer, primary_key=True)
        geometry = relationship(DocumentGeometry, uselist=False)

    schema = SQLAlchemySchemaNode(Document)

When I try to use schema.objectify({geometry: colander.null, document_id: null}), I was seeing the following error message:

    value = self[attr].objectify(dict_[attr])
  File ".../ColanderAlchemy/colanderalchemy/schema.py", line 687, in objectify
    for attr in dict_:
TypeError: '_null' object is not iterable

When the value for attribute geometry is colander.null, None should simply be used as value instead of trying to call objectify with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant