Re: [sqlalchemy] Default column value before an object is commited

2015-05-07 Thread Anton
On Wednesday, May 6, 2015 at 8:03:54 PM UTC-7, Michael Bayer wrote: Well it's already weird that you're defining both default and server_default at the same time on the Column. I'm not actually sure what effect that would have and am surprised it doesn't fail in some way...or at least

Re: [sqlalchemy] Default column value before an object is commited

2015-05-06 Thread Mike Bayer
On 5/6/15 9:43 PM, Anton wrote: I decided to use to an event based solution, but I did not want to duplicate default values in the listener function, so I trying to do it in the following way: | @event.listens_for(MyModel,'init') definit(target,args,kwargs): target_type =type(target)

[sqlalchemy] Default column value before an object is commited

2015-05-06 Thread Anton
*The goal* I have an ORM model. class MyModel(Model): __tablename__ = 'my_model' col1 = db.Column(db.Boolean, default=False, server_default=false()) col2 = db.Column(db.Integer, default=100, server_default=null()) I want to be able to create an object and have col1 and col2 be