No DEFAULT emitted with both server_default and server_onupdate
Issue #2631
resolved
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)
-
repo owner -
reporter Ah, wonderful that worked. Thanks a ton :)
-
repo owner - marked as blocker
- changed milestone to 0.8.0final
- changed status to resolved
pretty surprising that was like that.
3859742a91ef73755974a536a2f1a6937594d92b / default
-
repo owner - removed milestone
Removing milestone: 0.8.0final (automated comment)
- Log in to comment
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: