diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-12-18 20:09:14 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-12-18 20:09:14 +0000 |
commit | bc9e742b646f8dcd3e8a35c2ecda96bebed87d3c (patch) | |
tree | 3a3899ae6b7fa4769235a912a4d52ea7f5d00250 /lib/sqlalchemy | |
parent | fc175f478b4799ba69f457203103f48bdaa6a96d (diff) | |
download | sqlalchemy-bc9e742b646f8dcd3e8a35c2ecda96bebed87d3c.tar.gz |
- mysql: a column of type TIMESTAMP now defaults to NULL if
"nullable=False" is not passed to Column(), and no default
is present. This is now consistent with all other types,
and in the case of TIMESTAMP explictly renders "NULL"
due to MySQL's "switching" of default nullability
for TIMESTAMP columns. [ticket:1539]
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r-- | lib/sqlalchemy/dialects/mysql/base.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py index 01f8b13a7..e0610ec7e 100644 --- a/lib/sqlalchemy/dialects/mysql/base.py +++ b/lib/sqlalchemy/dialects/mysql/base.py @@ -1318,10 +1318,14 @@ class MySQLDDLCompiler(compiler.DDLCompiler): default = self.get_column_default_string(column) if default is not None: colspec.append('DEFAULT ' + default) - - if not column.nullable: + + is_timestamp = isinstance(column.type, sqltypes.TIMESTAMP) + if not column.nullable and not is_timestamp: colspec.append('NOT NULL') + elif column.nullable and is_timestamp and default is None: + colspec.append('NULL') + if column.primary_key and column.autoincrement: try: first = [c for c in column.table.primary_key.columns |