I have a model defined as
class Foo(Base): __tablename__ = 'foo' salt = Column(UUID, nullable=False, server_default = sqlalchemy.sql.expression.text('uuid_generate_v4()'))
According to the SqlAlchemy doc a text variable means
A text() expression will be rendered as-is, without quotes: Column('y', DateTime, server_default=text('NOW()'))0 y DATETIME DEFAULT NOW()
But the output of 'alembic -c development.ini --autogenerate -m "test"' is
op.create_table('foo', sa.Column('salt', postgresql.UUID(), server_default='uuid_generate_v4()', nullable=False) )
I tried to add compare_server_default to the configure call like this
context.configure( connection=connection, target_metadata=target_metadata, compare_server_default=True, )
but nothing changed.
This is especially annoying since it means that integer columns can't have a server_default defined in the model.
It is easy to fix manually by adding sa.text() around the generated server_default value in the version file but I know that we will forget that sometimes.
Am I doing something wrong or is this a bug?
Except for this everything have worked exactly as documented without any problems.