pyeve / eve-sqlalchemy

SQLAlchemy data layer for Eve-powered RESTful APIs
http://eve-sqlalchemy.readthedocs.io
Other
232 stars 70 forks source link

Nullable columns with a default set should not be "required" by registerSchema #87

Open fubu opened 8 years ago

fubu commented 8 years ago

A column of the form is_public = Column(Boolean, default=False, nullable=False) produces a schema with required=True, although the intention of the default argument is explicitly to not require a user to provide a value. The culprit is the registerSchema decorator.

I propose changing that line to something like:

                schema['required'] = not (col.nullable or col.default is None) \
                    if not col.primary_key else False
jeroenes commented 8 years ago

I second fubu's proposal.

Is there a workaround?

dkellner commented 7 years ago

I can confirm this bug. The right way to tackle this would be: