From SQLAlchemy docs:
nullable – If set to the default of True, indicates the column will be rendered as allowing NULL, else it’s rendered as NOT NULL. This parameter is only used when issuing CREATE TABLE statements.
I thought setting nullable=True
for a Column basically made that Column required. For example:
class Location(db.Model):
__tablename__ = 'locations'
id = db.Column(db.Integer, primary_key=True)
latitude = db.Column(db.String(50), nullable=False)
...
However, when I create a Location
instance without a latitude field, I do not get an error!
Python 2.7.8 (default, Oct 19 2014, 16:02:00)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.54)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> Location(latitude=None)
<app.models.Location object at 0x10dce9dd0>
What is going on?