weixin_39890652 2020-11-30 11:37
浏览 0

Create date column with "server_default='now()'" add current date in db as default instead of "now()"

Migrated issue, originally created by le-stagiaire


op.create_table('test', sa.Column('date', sa.DateTime(), server_default='now()', nullable=False))

On PSQL: 10.5 Alembic : 1.0.0 Sqlalchemy : 1.2.10

I've tested with possible value, like 'sa.func.now()', or 'now' with the parentheses, ... I think this is more of a sqlalchemy error, but it's when we use it in alembic that the sql generated is bad so ... And also I cannot create issue on sqlalchemy repo :$

该提问来源于开源项目:sqlalchemy/alembic

  • 写回答

4条回答 默认 最新

  • weixin_39890652 2020-11-30 11:37
    关注

    le-stagiaire wrote:

    Thanks for the quick and qualitative reply ! I close the issue, almost sure my falsy column prop in sqlalchemy used to work in autogenerate before and must had gave me the 'sa.text('now()') that I didn't noticed, but now it's for the better !

    Again, thank you

    评论

报告相同问题?