class MyObject(Entity):
name = Field(Unicode(256), default=u'default name', nullable=False)
using_options(shortnames=True)
using_mapper_options(save_on_init=False)
def __init__(self):
self.name = None
I am using MySQL in this case, but have also checked against SQLite and I get the same result. It respects nullable
, but ignores default
entirely. I don't get any error messages, and it creates the tables just fine. I could go back through and add the defaults, but this is a serious pain that I would like to avoid if possible.
I've tried it with other Field types, but still no joy.
default
keyword argument in SQLAlchemy is for Python runtime default value, it's used for INSERT statements. Use PassiveDefault()
object as positional argument when you really need database level default.