11 messages in com.googlegroups.sqlalchemy[sqlalchemy] Default value for object...
FromSent OnAttachments
Jonathan Ballet30 Jul 2007 08:50 
Michael Bayer30 Jul 2007 10:36 
Jonathan Ballet30 Jul 2007 11:26 
sdob...@sistechnology.com30 Jul 2007 12:15 
Michael Bayer30 Jul 2007 13:33 
Paul Johnston30 Jul 2007 16:29 
Jonathan Ballet31 Jul 2007 01:11 
Michael Bayer31 Jul 2007 07:35 
Paul Johnston31 Jul 2007 08:30 
Michael Bayer31 Jul 2007 09:26 
Paul Johnston01 Aug 2007 13:23 
Subject:[sqlalchemy] Default value for objects' attributes
From:Jonathan Ballet (mult@free.fr)
Date:07/30/2007 08:50:48 AM
List:com.googlegroups.sqlalchemy

Hi,

we ran into a small problem today, related to default values for table's columns. Here an example :

test = Table('test', metadata, Column('id', Integer, primary_key=True), Column('test_value', Boolean, default=False, nullable=False) ) class Test(object):pass test_mapper = mapper(Test, test)

metadata is a bound metadata connected on a PostgreSQL (8.1) database.

The problem is that creating a new object from class Test doesn't set the default value for attributes :

t = Test() print t.test_value

None

(However, the default value is used just before inserting the object in the database, which is fine).

Is there an easy way to have attributes set to there default values, instead of None ?

Thanks, - Jonathan