No DEFAULT emitted with both server_default and server_onupdate

Issue #2631 resolved
Donald Stufft created an issue

Using 0.7.9 but also tested with tip (d4d0e97) w/ Postgresql and psycopg2.

I have a field for a timestamp, when I have only a server_default clause, it creates the table fine, but when I include the server_onupdate clause it no longer emits the DEFAULT now() clause when creating the database. Here's the code:

# modified timestamp without time zone NOT NULL
modified = db.Column(db.DateTime, nullable=False, server_default=func.now(), server_onupdate=FetchedValue())



# modified timestamp without time zone NOT NULL DEFAULT now()
modified = db.Column(db.DateTime, nullable=False, server_default=func.now())

Comments (4)

  1. Mike Bayer repo owner

    this is a bug, in that the API which works correctly here is sort of impossible for anyone to know, but here is the secret sauce for the moment:

    c = Column('x', Integer, server_default=func.now(), server_onupdate=FetchedValue(for_update=True))
    
  2. Log in to comment